示例#1
0
 @Override
 public String getWorker(String issueKey) {
   Worker[] workers = ao.find(Worker.class, Query.select().where("ISSUE_KEY = ?", issueKey));
   if (workers.length == 0) return null;
   if (workers.length > 1) log.error("found more than one worker for one issue");
   return workers[0].getWorkerUser();
 }
示例#2
0
 @Override
 public Rate[] getAll() {
   // try {
   return ao.find(Rate.class, Query.select().order("WHOM, \"ISSUE_KEY\""));
   // } catch ()
   // this \"ISSUE_KEY\" because f*****g bug that causes query like this with normal style :
   // SELECT "ID" FROM public."AO_A15A5A_RATE" ORDER BY "WHOM", ISSUE_KEY
 }
示例#3
0
 @Override
 public List<Rate> getRatesForUser(List<String> userNames, Date start, Date end, String... order) {
   List<Rate> result = new ArrayList<Rate>();
   for (String userName : userNames) {
     Query q = Query.select().where("WHOM IN (?) AND WHEN BETWEEN ? AND ?", userName, start, end);
     if (order.length != 0) {
       q = q.order(mkOrderString(order)); // oh mein gott **** me harder
     }
     Rate[] rates = ao.find(Rate.class, q);
     Collections.addAll(result, rates);
   }
   return result;
 }
示例#4
0
 @Override
 public void setWorker(String issueKey, String username) {
   Worker[] workers = ao.find(Worker.class, Query.select().where("ISSUE_KEY = ?", issueKey));
   if (workers.length > 1) log.error("found more than one worker for one issue");
   if (workers.length == 0) {
     ao.create(Worker.class, EasyMap.build("ISSUE_KEY", issueKey, "WORKER_USER", username));
   } else {
     Worker worker = workers[0];
     String oldUserName = worker.getWorkerUser();
     if (oldUserName.equals(username)) return;
     worker.setWorkerUser(username);
     worker.save();
   }
 }
 // static methods for getting by id, etc.
 public static PullRequestDisapproval getPullRequestDisapproval(ActiveObjects ao, PullRequest pr)
     throws SQLException {
   Repository repo = pr.getToRef().getRepository();
   PullRequestDisapproval[] disapprovals =
       ao.find(
           PullRequestDisapproval.class,
           Query.select().where("REPO_ID = ? and PR_ID = ?", repo.getId(), pr.getId()));
   if (disapprovals.length == 0) {
     PullRequestDisapproval prd =
         ao.create(
             PullRequestDisapproval.class,
             new DBParam("REPO_ID", repo.getId()),
             new DBParam("PR_ID", pr.getId()),
             new DBParam("USERNAME", "None"));
     prd.save();
     return prd;
   }
   return disapprovals[0];
 }
 public static void setPullRequestDisapproval(
     ActiveObjects ao, PullRequest pr, String username, boolean isDisapproved)
     throws SQLException {
   Repository repo = pr.getToRef().getRepository();
   PullRequestDisapproval[] disapprovals =
       ao.find(
           PullRequestDisapproval.class,
           Query.select().where("REPO_ID = ? and PR_ID = ?", repo.getId(), pr.getId()));
   if (disapprovals.length == 0) {
     PullRequestDisapproval prd =
         ao.create(
             PullRequestDisapproval.class,
             new DBParam("REPO_ID", repo.getId()),
             new DBParam("PR_ID", pr.getId()),
             new DBParam("USERNAME", username));
     prd.setDisapproved(isDisapproved);
     prd.save();
     return;
   }
   disapprovals[0].setDisapprovedBy(username);
   disapprovals[0].setDisapproved(isDisapproved);
   disapprovals[0].save();
 }
示例#7
0
 private Rate[] _getRatesForIssue(String issueKey) {
   return ao.find(Rate.class, Query.select().where("ISSUE_KEY = ?", issueKey));
 }