*/
-public class RooRepo : Object
-{
-
-
-
- public string id; // not really important that they are numbers..
- public string project_id;
- public string description;
- public string shortname;
-
-
-}
public class RooOption : Object
{
}
-public class RooProject : Object
-{
- public string id; // not really important that they are numbers..
- public string code;
- public string name;
- public string type;
-
-}
-
-
static RooTicket _RooTicket;
ME
}
public enum Status {
- ANY,
+ ALL,
ACTIVE
}
if (_RooTicket == null) {
_RooTicket = new RooTicket();
_RooTicket.tickets = new Gee.ArrayList<RooTicket>();
- _RooTicket.projects = new Gee.ArrayList<RooProject>();
- _RooTicket.repos = new Gee.ArrayList<RooRepo>();
- _RooTicket.loadRepos(); // initalize it..
+
+
+
}
return _RooTicket;
}
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;
GLib.debug("ADD ticket %s : %s : %s", add.id, add.summary, add.project_id_name);
return add;
}
- public RooProject addProject(Json.Object t)
- {
- var add = new RooProject();
- add.id = t.get_string_member("id");
- add.name = t.get_string_member("name");
- add.type = t.get_string_member("type");
- add.code = t.get_string_member("code");
- this.projects.add(add);
- GLib.debug("ADD project %s : %s : %s", add.id, add.code, add.name);
- return add;
- }
-
- public RooRepo addRepo(Json.Object t)
- {
- var add = new RooRepo();
- add.id = t.get_string_member("id");
- add.shortname = t.get_string_member("shortname");
- add.description = t.get_string_member("description");
- add.project_id = t.get_string_member("project_id");
- this.repos.add(add);
- GLib.debug("ADD project %s : %s : %s", add.id, add.shortname, add.project_id);
- return add;
- }
-
- public RooProject? getProjectByRepo(GitRepo repo)
- {
- var rt = RooTicket.singleton();
-
- if (rt.repos.size < 1) {
- rt.loadRepos();
- }
- if (rt.projects.size < 1) {
- rt.loadProjects();
- }
-
- var pid = "";
- foreach(var roo_repo in rt.repos) {
- if (roo_repo.shortname == repo.name) {
- pid = roo_repo.project_id;
- break;
- }
- }
- if (pid == "") {
- GLib.debug("getProjectByRepo: repo has no project");
- return null;
- }
- // get project by id...
- foreach(var roo_project in rt.projects) {
- if (roo_project.id == pid) {
- GLib.debug("getProjectByRepo: project_id = %s", pid);
- return roo_project;
- }
- }
- GLib.debug("getProjectByRepo: can not find project");
- return null;
-
- }
+
+
+
public static RooTicket fakeTicket()
var table = new GLib.HashTable<string, string>(str_hash, str_equal);
- table.insert("_developer", who.to_string().down());
+ table.insert("_developer", who.to_string().down().substring(15));
- table.insert("query[viewtype]", status.to_string().down());
+ table.insert("query[viewtype]", status.to_string().down().substring(18));
- table.insert("limit","999");
+ table.insert("limit","200");
table.insert("sort","summary");
table.insert("dir","ASC");
}
-
- public void loadProjects()
- {
- RooTicket.singleton().projects = new Gee.ArrayList<RooProject>();
-
-
- var table = new GLib.HashTable<string, string>(str_hash, str_equal);
-
- table.insert("query[project_filter]","P,N,U");
- table.insert("limit","999");
- table.insert("sort","name");
- table.insert("dir","ASC");
-
- var params = Soup.Form.encode_hash(table);
-
- var url = "%s/%s?%s" . printf(roourl, "core_project", params);
-
- GLib.debug("request %s", url);
-
- var session = new Soup.Session ();
- session.timeout = 0;
- var message = new Soup.Message ("GET", url);
-
-
- RooTicket.setAuth(message);
-
- session.send_message (message);
-
- var data = (string) message.response_body.flatten().data;
- //GLib.debug("got %s", data);
- try {
- var parser = new Json.Parser ();
- parser.load_from_data (data, -1);
-
- var response = parser.get_root().get_object();
- var status = response.get_boolean_member("success");
-
- if(!status){
- GLib.error(response.get_string_member("errorMsg"));
- return;
- }
- var rd = response.get_array_member ("data");
-
- // got a valid result...
- var _this = RooTicket.singleton();
- for(var i = 0; i < rd.get_length(); i++) {
- _this.addProject(rd.get_object_element(i));
- }
-
-
- } catch (Error e) {
- GLib.error(e.message);
- return;
- }
-
- }
- public void loadRepos()
- {
- RooTicket.singleton().repos = new Gee.ArrayList<RooRepo>();
-
-
- var table = new GLib.HashTable<string, string>(str_hash, str_equal);
-
-
- table.insert("limit","999");
- table.insert("sort","shortname");
- table.insert("dir","ASC");
-
- var params = Soup.Form.encode_hash(table);
-
- var url = "%s/%s?%s" . printf(roourl, "mtrack_repos", params);
-
- GLib.debug("request %s", url);
-
- var session = new Soup.Session ();
- session.timeout = 0;
- var message = new Soup.Message ("GET", url);
-
-
- RooTicket.setAuth(message);
-
- session.send_message (message);
-
- var data = (string) message.response_body.flatten().data;
- //GLib.debug("got %s", data);
- try {
- var parser = new Json.Parser ();
- parser.load_from_data (data, -1);
-
- var response = parser.get_root().get_object();
- var status = response.get_boolean_member("success");
-
- if(!status){
- GLib.error(response.get_string_member("errorMsg"));
- return;
- }
- var rd = response.get_array_member ("data");
-
- // 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) {
- GLib.error(e.message);
- return;
- }
-
- }
+
public void loadProjectOptions(string pid)
{
var rt = RooTicket.singleton();
string project_id,
string milestone_id,
string priority_id,
+ string severity_id,
string classification_id,
string developer_id,
string summary,
table.insert("project_id", project_id);
table.insert("milestone_id", milestone_id);
table.insert("priority_id", priority_id);
+ table.insert("severity_id", classification_id);
table.insert("classification_id", classification_id);
table.insert("developer_id", developer_id);
table.insert("summary", summary);