Пример #1
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();
   }
 }
Пример #2
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();
 }
Пример #3
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
 }
 // 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];
 }
Пример #5
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;
 }
 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
 @Override
 public void addRating(String issueKey, String who, String whom, int rating, String comment) {
   ao.create(
       Rate.class,
       EasyMap.build(
           "ISSUE_KEY",
           issueKey,
           "WHO",
           who,
           "WHOM",
           whom,
           "RATING",
           rating,
           "COMMENT",
           comment,
           "WHEN",
           new Date()));
 }
Пример #8
0
 private Rate[] _getRatesForIssue(String issueKey) {
   return ao.find(Rate.class, Query.select().where("ISSUE_KEY = ?", issueKey));
 }