Ejemplo n.º 1
1
 public static void toInProgress(JiraRestClient restClient, Issue issue) {
   Iterable<Transition> transitions = null;
   Transition assignToRunTransition = null, inProgressTransition = null, reRunTransition = null;
   String statusName = issue.getStatus().getName();
   System.out.println("status is " + statusName + "/" + issue.getTransitionsUri().toString());
   if (statusName.equals("Create") || statusName.equals("Open") || statusName.equals("Reopened")) {
     // do nothing
     transitions = restClient.getIssueClient().getTransitions(issue.getTransitionsUri()).claim();
     inProgressTransition = getTransitionByName(transitions, "Start Progress");
     restClient
         .getIssueClient()
         .transition(
             issue.getTransitionsUri(), new TransitionInput(4 /*inProgressTransition.getId()*/))
         .claim();
   } else if (statusName.equals("In Progress")) {
     /*只能在这里获得, 因为状态不同, transition不同*/
   } else if (statusName.equals("Resolved")) {
     transitions = restClient.getIssueClient().getTransitions(issue.getTransitionsUri()).claim();
     inProgressTransition = getTransitionByName(transitions, "Reopen Issue");
     restClient
         .getIssueClient()
         .transition(issue.getTransitionsUri(), new TransitionInput(inProgressTransition.getId()))
         .claim();
     transitions = restClient.getIssueClient().getTransitions(issue.getTransitionsUri()).claim();
     assignToRunTransition = getTransitionByName(transitions, "Start Progress");
     restClient
         .getIssueClient()
         .transition(issue.getTransitionsUri(), new TransitionInput(assignToRunTransition.getId()))
         .claim();
   } else if (statusName.equals("Closed")) {
     System.out.println(issue.getId() + ", " + statusName + ", closed, do nothing.");
   } else {
     /*状态修改过, 程序没有改动.*/
     throw new RuntimeException("status error.");
   }
 }
Ejemplo n.º 2
0
  /**
   * Implementation of TicketerPlugin API call to retrieve a Jira trouble ticket.
   *
   * @return an OpenNMS
   * @throws PluginException
   */
  @Override
  public Ticket get(String ticketId) throws PluginException {
    JiraRestClient jira = getConnection();
    if (jira == null) {
      return null;
    }

    // w00t
    Issue issue;
    try {
      issue = jira.getIssueClient().getIssue(ticketId).get();
    } catch (InterruptedException | ExecutionException e) {
      throw new PluginException("Failed to get issue with id: " + ticketId, e);
    }

    if (issue != null) {
      Ticket ticket = new Ticket();

      ticket.setId(issue.getKey());
      ticket.setModificationTimestamp(String.valueOf(issue.getUpdateDate().toDate().getTime()));
      ticket.setSummary(issue.getSummary());
      ticket.setDetails(issue.getDescription());
      ticket.setState(getStateFromStatusName(issue.getStatus().getName()));

      return ticket;
    } else {
      return null;
    }
  }