RooTicket.vala
[gitlive] / RooTicket.vala
index 5713292..558c98e 100644 (file)
@@ -13,10 +13,25 @@ public class RooRepo : Object
        public string project_id;
        public string description;
        public string shortname;
+       
+
+}
 
+public class RooOption : Object 
+{
+       
+       public string id; // not really important that they are numbers..
+       public string display_name;
+       public RooOption (string id, string name)
+       {
+               this.id = id;
+               this.display_name = name;
+       }
 
 }
 
+
 public class RooProject  : Object 
 {
        public string  id; // not really important that they are numbers..
@@ -89,6 +104,19 @@ public class RooTicket : Object
        
        }
 
+       public Gee.ArrayList<RooOption> readJsonArray(Json.Array a)
+       {
+               var ret = new Gee.ArrayList<RooOption>();
+               for(var i = 0; i < a.get_length(); i++) {
+                       var t = a.get_object_element(i);
+                       ret += new RooOption(
+                               t.get_string_member("id"),
+                               t.get_string_member("display_name")
+                       );
+               }
+               return ret;
+                        
+       }
 
        public RooTicket addTicket(Json.Object t)
        {
@@ -419,7 +447,6 @@ public class RooTicket : Object
                
                var table = new GLib.HashTable<string, string>(str_hash, str_equal);
         
-
                table.insert("_options_for",pid);
 
                var params = Soup.Form.encode_hash(table);
@@ -452,6 +479,15 @@ public class RooTicket : Object
                        }
                        var rd = response.get_array_member ("data");
                        
+                       this.milestones = this.readJsonArray( rd.get_array_member("milestone"));
+                       this.priorities = this.readJsonArray( rd.get_array_member("priority"));
+                       this.serverities = this.readJsonArray( rd.get_array_member("severity"));
+                       this.classifications  = this.readJsonArray( rd.get_array_member("classification"));
+                       this.developers = this.readJsonArray( rd.get_array_member("developer"));
+                       
+                       
+                       
                        // got a valid result...
                        var _this = RooTicket.singleton();
                        for(var i = 0; i < rd.get_length(); i++) {