Ticket.bjs
[gitlive] / RooTicket.vala
index 5713292..a66a968 100644 (file)
@@ -1,4 +1,4 @@
-/**
+/** 
 
 code to fetch ticket info...
 
@@ -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..
@@ -58,6 +73,14 @@ public class RooTicket : Object
        public Gee.ArrayList<RooTicket> tickets; // only available for singletonn.
        public Gee.ArrayList<RooProject> projects; // only available for singletonn.    
        public Gee.ArrayList<RooRepo> repos; // only available for singletonn.          
+       
+       public Gee.ArrayList<RooOption> milestones;
+       public Gee.ArrayList<RooOption> priorities;
+       public Gee.ArrayList<RooOption> serverities;
+       public Gee.ArrayList<RooOption> classifications;
+       public Gee.ArrayList<RooOption> developers;
+                
+       
        public string username = ""; // only available for singletonn.
        public string password = ""; // only available for singletonn.
 
@@ -89,6 +112,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.add(new RooOption(
+                               t.get_string_member("id"),
+                               t.get_string_member("display_name")
+                       ));
+               }
+               return ret;
+                        
+       }
 
        public RooTicket addTicket(Json.Object t)
        {
@@ -414,12 +450,11 @@ public class RooTicket : Object
        }
        public void loadProjectOptions(string pid)
        {
-               RooTicket.singleton().repos = new Gee.ArrayList<RooRepo>();
-        
-               
+
+               var rt = RooTicket.singleton();
+
                var table = new GLib.HashTable<string, string>(str_hash, str_equal);
         
-
                table.insert("_options_for",pid);
 
                var params = Soup.Form.encode_hash(table);
@@ -450,13 +485,18 @@ public class RooTicket : Object
                                GLib.error(response.get_string_member("errorMsg"));
                                return;
                        }
-                       var rd = response.get_array_member ("data");
+                       var rd = response.get_object_member ("data");
+                       
+                       rt.milestones = this.readJsonArray( rd.get_array_member("milestone"));
+                       rt.priorities = this.readJsonArray( rd.get_array_member("priority"));
+                       rt.serverities = this.readJsonArray( rd.get_array_member("severity"));
+                       rt.classifications  = this.readJsonArray( rd.get_array_member("classification"));
+                       rt.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++) {
-                               _this.addRepo(rd.get_object_element(i));
-                       }
                         
                
                } catch (Error e) {