@Override
 protected Issue run(Account account) throws Exception {
   Issue editedIssue = new Issue();
   editedIssue.setNumber(issueNumber);
   editedIssue.setMilestone(new Milestone().setNumber(milestoneNumber));
   return store.editIssue(repositoryId, editedIssue);
 }
  public List<Issue> getIssueList() throws IOException {
    List<Issue> issueList = new ArrayList<Issue>();

    IssueService service = new IssueService(client);
    Map<String, String> issueFilter = new HashMap<String, String>();

    if (includeOpenIssues) {
      // Adding open issues

      for (org.eclipse.egit.github.core.Issue issue :
          service.getIssues(githubOwner, githubRepo, issueFilter)) {
        if (!onlyMilestoneIssues || issue.getMilestone() != null) {
          issueList.add(createIssue(issue));
        }
      }
    }

    // Adding closed issues

    issueFilter.put("state", "closed");

    for (org.eclipse.egit.github.core.Issue issue :
        service.getIssues(githubOwner, githubRepo, issueFilter)) {
      if (!onlyMilestoneIssues || issue.getMilestone() != null) {
        issueList.add(createIssue(issue));
      }
    }

    return issueList;
  }
  /**
   * Create issue map for issue
   *
   * @param issue
   * @param newIssue
   * @return map
   */
  protected Map<Object, Object> createIssueMap(Issue issue, boolean newIssue) {
    Map<Object, Object> params = new HashMap<Object, Object>();
    if (issue != null) {
      params.put(FIELD_BODY, issue.getBody());
      params.put(FIELD_TITLE, issue.getTitle());
      User assignee = issue.getAssignee();
      if (assignee != null) params.put(FILTER_ASSIGNEE, assignee.getName());

      Milestone milestone = issue.getMilestone();
      if (milestone != null) {
        int number = milestone.getNumber();
        if (number > 0) params.put(FILTER_MILESTONE, Integer.toString(number));
        else {
          if (!newIssue) params.put(FILTER_MILESTONE, null);
        }
      }
      List<Label> labels = issue.getLabels();
      if (labels != null) {
        List<String> labelNames = new ArrayList<String>(labels.size());
        for (Label label : labels) labelNames.add(label.getName());
        params.put(FILTER_LABELS, labelNames);
      }
    }
    return params;
  }
 @Override
 protected Issue run(Account account) throws Exception {
   Issue editedIssue = new Issue();
   editedIssue.setNumber(issueNumber);
   if (close) editedIssue.setState(STATE_CLOSED);
   else editedIssue.setState(STATE_OPEN);
   return store.editIssue(repositoryId, editedIssue);
 }
  @RequestMapping("/output")
  public String func(HttpServletRequest req, HttpServletResponse resp) throws Exception {
    String outputURL = "first";

    try {
      String path = req.getParameter("path");
      // System.out.println(path);
      String arr[] = path.split("/");
      String repoName = arr[arr.length - 1];
      String user = arr[arr.length - 2];
      // System.out.println(user+" - " +path);

      Set<Issue> lessSeven = new LinkedHashSet<Issue>();
      Set<Issue> between24and7 = new LinkedHashSet<Issue>();
      Set<Issue> greaterSeven = new LinkedHashSet<Issue>();

      Date yesterday = new Date(System.currentTimeMillis() - (24 * 60 * 60 * 1000));
      // String yesterdayDate=sdf.format(yesterday);
      Date DaysAgo7Date = new Date(System.currentTimeMillis() - 7 * 24 * 60 * 60 * 1000);
      // String DaysAgo7=sdf.format(DaysAgo7Date);

      GitHubClient git = new GitHubClient();
      // git.setOAuth2Token("39de076299133c5c995ee00b1573f9826887e5bd");
      git.setCredentials("TheMask", "sugandh4");
      RepositoryService repoService = new RepositoryService(git);
      IssueService issueService = new IssueService(git);
      Repository repo = null;
      repo = repoService.getRepository(user, repoName);

      System.out.println(repo.getName());
      System.out.println(repo.getOpenIssues());
      Map<String, String> paramIssue = new HashMap<String, String>();
      paramIssue.put("state", "open");
      // paramIssue.put("sort", "created");
      List<Issue> issueList = issueService.getIssues(repo, paramIssue);
      for (Issue issue : issueList) {
        // System.out.println(issue.getCreatedAt());
        if (issue.getCreatedAt().after(yesterday)) lessSeven.add(issue);
        else if ((issue.getCreatedAt().before(yesterday))
            && (issue.getCreatedAt().after(DaysAgo7Date))) between24and7.add(issue);
        else greaterSeven.add(issue);
      }

      HttpSession session = req.getSession();
      session.setAttribute("firstList", lessSeven);
      session.setAttribute("secondList", between24and7);
      session.setAttribute("thirdList", greaterSeven);
    } catch (Exception e) {
      System.out.println(e.getMessage());
      outputURL = "error";
    }

    System.out.println(outputURL);
    return outputURL;
  }
  /**
   * Edit issue
   *
   * @param user
   * @param repository
   * @param issue
   * @return created issue
   * @throws IOException
   */
  public Issue editIssue(String user, String repository, Issue issue) throws IOException {
    Assert.notNull("User cannot be null", user); // $NON-NLS-1$
    Assert.notNull("Repository cannot be null", repository); // $NON-NLS-1$
    Assert.notNull("Issue cannot be null", issue); // $NON-NLS-1$
    StringBuilder uri = new StringBuilder(IGitHubConstants.SEGMENT_REPOS);
    uri.append('/').append(user).append('/').append(repository);
    uri.append(IGitHubConstants.SEGMENT_ISSUES);
    uri.append('/').append(issue.getNumber());

    Map<Object, Object> params = createIssueMap(issue, false);
    String state = issue.getState();
    if (state != null) params.put(FILTER_STATE, state);
    return this.client.post(uri.toString(), params, Issue.class);
  }
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case R.id.m_edit:
       if (issue != null)
         startActivityForResult(
             EditIssueActivity.createIntent(
                 issue, repositoryId.getOwner(), repositoryId.getName(), user),
             ISSUE_EDIT);
       return true;
     case R.id.m_comment:
       if (issue != null)
         startActivityForResult(
             CreateCommentActivity.createIntent(repositoryId, issueNumber, user), COMMENT_CREATE);
       return true;
     case R.id.m_refresh:
       refreshIssue();
       return true;
     case R.id.m_share:
       if (issue != null) shareIssue();
       return true;
     case R.id.m_state:
       if (issue != null) stateTask.confirm(STATE_OPEN.equals(issue.getState()));
       return true;
     default:
       return super.onOptionsItemSelected(item);
   }
 }
  private void openPullRequestCommits() {
    if (IssueUtils.isPullRequest(issue)) {
      PullRequest pullRequest = issue.getPullRequest();

      String base = pullRequest.getBase().getSha();
      String head = pullRequest.getHead().getSha();
      Repository repo = pullRequest.getBase().getRepo();
      startActivity(CommitCompareViewActivity.createIntent(repo, base, head));
    }
  }
  @Override
  public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (RESULT_OK != resultCode || data == null) return;

    switch (requestCode) {
      case ISSUE_EDIT:
        Issue editedIssue = (Issue) data.getSerializableExtra(EXTRA_ISSUE);
        bodyImageGetter.encode(editedIssue.getId(), editedIssue.getBodyHtml());
        updateHeader(editedIssue);
        break;
      case COMMENT_CREATE:
        Comment comment = (Comment) data.getSerializableExtra(EXTRA_COMMENT);
        if (items != null) {
          items.add(comment);
          issue.setComments(issue.getComments() + 1);
          updateList(issue, items);
        } else refreshIssue();
        break;
      case COMMENT_EDIT:
        // TODO: update the commit without reloading the full issue
        refreshIssue();
        break;
    }
  }
  @Override
  public void onCreateOptionsMenu(Menu optionsMenu, MenuInflater inflater) {
    inflater.inflate(R.menu.issue_view, optionsMenu);
    MenuItem editItem = optionsMenu.findItem(R.id.m_edit);
    stateItem = optionsMenu.findItem(R.id.m_state);
    if (editItem != null && stateItem != null) {
      boolean canEdit;
      if (issue != null) canEdit = isCollaborator || issue.getUser().getLogin().equals(loggedUser);
      else canEdit = isCollaborator;

      editItem.setVisible(canEdit);
      stateItem.setVisible(canEdit);
    }
    updateStateItem(issue);
  }
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    adapter.addHeader(headerView);
    adapter.addFooter(footerView);

    issue = store.getIssue(repositoryId, issueNumber);

    TextView loadingText = (TextView) loadingView.findViewById(R.id.tv_loading);
    loadingText.setText(R.string.loading_comments);

    if (issue == null || (issue.getComments() > 0 && items == null)) adapter.addHeader(loadingView);

    if (issue != null && items != null) updateList(issue, items);
    else {
      if (issue != null) updateHeader(issue);
      refreshIssue();
    }
  }
 private void updateStateItem(Issue issue) {
   if (issue != null && stateItem != null)
     if (STATE_OPEN.equals(issue.getState()))
       stateItem.setTitle(R.string.close).setIcon(R.drawable.menu_issue_close);
     else stateItem.setTitle(R.string.reopen).setIcon(R.drawable.menu_issue_open);
 }
  protected Issue createIssue(org.eclipse.egit.github.core.Issue githubIssue) {
    Issue issue = new Issue();

    issue.setKey(String.valueOf(githubIssue.getNumber()));
    issue.setId(String.valueOf(githubIssue.getNumber()));

    issue.setLink(this.githubIssueURL + githubIssue.getNumber());

    issue.setCreated(githubIssue.getCreatedAt());

    issue.setUpdated(githubIssue.getUpdatedAt());

    if (githubIssue.getAssignee() != null) {
      if (githubIssue.getAssignee().getName() != null) {
        issue.setAssignee(githubIssue.getAssignee().getName());
      } else {
        issue.setAssignee(githubIssue.getAssignee().getLogin());
      }
    }

    issue.setTitle(githubIssue.getTitle());

    issue.setSummary(githubIssue.getTitle());

    if (githubIssue.getMilestone() != null) {
      issue.addFixVersion(githubIssue.getMilestone().getTitle());
    }

    issue.setReporter(githubIssue.getUser().getLogin());

    if (githubIssue.getClosedAt() != null) {
      issue.setStatus("closed");
    } else {
      issue.setStatus("open");
    }

    List<Label> labels = githubIssue.getLabels();
    if (labels != null && !labels.isEmpty()) {
      issue.setType(labels.get(0).getName());
    }

    return issue;
  }
Example #14
0
 /**
  * Add issue to intent being built up
  *
  * @param issue
  * @return this builder
  */
 public Builder issue(Issue issue) {
   return repo(createFromUrl(issue.getHtmlUrl()))
       .add(EXTRA_ISSUE, issue)
       .add(EXTRA_ISSUE_NUMBER, issue.getNumber());
 }
  private void updateHeader(final Issue issue) {
    if (!isUsable()) return;

    boolean isPullRequest = IssueUtils.isPullRequest(issue);
    titleText.setText(issue.getTitle());

    String body = issue.getBodyHtml();
    if (!TextUtils.isEmpty(body)) bodyImageGetter.bind(bodyText, body, issue.getId());
    else bodyText.setText(R.string.no_description_given);

    authorText.setText(issue.getUser().getLogin());
    createdDateText.setText(
        new StyledText().append(getString(R.string.prefix_opened)).append(issue.getCreatedAt()));
    avatars.bind(creatorAvatar, issue.getUser());

    if (isPullRequest && issue.getPullRequest().getCommits() > 0) {
      ViewUtils.setGone(commitsView, false);

      TextView icon = (TextView) headerView.findViewById(R.id.tv_commit_icon);
      TypefaceUtils.setOcticons(icon);
      icon.setText(TypefaceUtils.ICON_GIT_COMMIT);

      String commits =
          getString(R.string.pull_request_commits, issue.getPullRequest().getCommits());
      ((TextView) headerView.findViewById(R.id.tv_pull_request_commits)).setText(commits);
    } else ViewUtils.setGone(commitsView, true);

    boolean open = STATE_OPEN.equals(issue.getState());
    if (!open) {
      StyledText text = new StyledText();
      if (isPullRequest && issue.getPullRequest().isMerged()) {
        text.bold(getString(R.string.merged));
        stateText.setBackgroundResource(R.color.state_background_merged);
      } else {
        text.bold(getString(R.string.closed));
        stateText.setBackgroundResource(R.color.state_background_closed);
      }
      Date closedAt = issue.getClosedAt();
      if (closedAt != null) text.append(' ').append(closedAt);
      stateText.setText(text);
    }
    ViewUtils.setGone(stateText, open);

    User assignee = issue.getAssignee();
    if (assignee != null) {
      StyledText name = new StyledText();
      name.bold(assignee.getLogin());
      name.append(' ').append(getString(R.string.assigned));
      assigneeText.setText(name);
      assigneeAvatar.setVisibility(VISIBLE);
      avatars.bind(assigneeAvatar, assignee);
    } else {
      assigneeAvatar.setVisibility(GONE);
      assigneeText.setText(R.string.unassigned);
    }

    List<Label> labels = issue.getLabels();
    if (labels != null && !labels.isEmpty()) {
      LabelDrawableSpan.setText(labelsArea, labels);
      labelsArea.setVisibility(VISIBLE);
    } else labelsArea.setVisibility(GONE);

    if (issue.getMilestone() != null) {
      Milestone milestone = issue.getMilestone();
      StyledText milestoneLabel = new StyledText();
      milestoneLabel.append(getString(R.string.milestone_prefix));
      milestoneLabel.append(' ');
      milestoneLabel.bold(milestone.getTitle());
      milestoneText.setText(milestoneLabel);
      float closed = milestone.getClosedIssues();
      float total = closed + milestone.getOpenIssues();
      if (total > 0) {
        ((LayoutParams) milestoneProgressArea.getLayoutParams()).weight = closed / total;
        milestoneProgressArea.setVisibility(VISIBLE);
      } else milestoneProgressArea.setVisibility(GONE);
      milestoneArea.setVisibility(VISIBLE);
    } else milestoneArea.setVisibility(GONE);

    String state = issue.getState();
    if (state != null && state.length() > 0)
      state = state.substring(0, 1).toUpperCase(Locale.US) + state.substring(1);
    else state = "";

    ViewUtils.setGone(progress, true);
    ViewUtils.setGone(list, false);
    updateStateItem(issue);
  }
Example #16
0
 private static boolean isPullRequest(Issue issue) {
   return issue.getPullRequest() != null && issue.getPullRequest().getUrl() != null;
 }
Example #17
0
  public TurboIssue(String repoId, Issue issue) {
    this.id = issue.getNumber();
    this.title = issue.getTitle() == null ? "" : issue.getTitle();
    this.creator = issue.getUser().getLogin();
    this.createdAt = Utility.dateToLocalDateTime(issue.getCreatedAt());
    this.isPullRequest = isPullRequest(issue);

    this.description = issue.getBody() == null ? "" : issue.getBody();
    this.updatedAt =
        issue.getUpdatedAt() != null
            ? Utility.dateToLocalDateTime(issue.getUpdatedAt())
            : this.createdAt;
    this.commentCount = issue.getComments();
    this.isOpen = issue.getState().equals(STATE_OPEN);
    this.assignee =
        issue.getAssignee() == null
            ? Optional.empty()
            : Optional.of(issue.getAssignee().getLogin());
    this.labels = issue.getLabels().stream().map(Label::getName).collect(Collectors.toList());
    this.milestone =
        issue.getMilestone() == null
            ? Optional.empty()
            : Optional.of(issue.getMilestone().getNumber());

    this.metadata = IssueMetadata.empty();
    this.repoId = repoId;
    this.markedReadAt = Optional.empty();
  }
Example #18
0
  protected void updateEvent(final IssueEvent event) {
    TypefaceUtils.setOcticons(textView(0));
    String message = String.format("<b>%s</b> %s", event.getActor().getLogin(), event.getEvent());
    avatars.bind(imageView(2), event.getActor());

    String eventString = event.getEvent();

    switch (eventString) {
      case "assigned":
      case "unassigned":
        setText(0, TypefaceUtils.ICON_PERSON);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "labeled":
      case "unlabeled":
        setText(0, TypefaceUtils.ICON_TAG);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "referenced":
        setText(0, TypefaceUtils.ICON_BOOKMARK);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "milestoned":
      case "demilestoned":
        setText(0, TypefaceUtils.ICON_MILESTONE);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "closed":
        setText(0, TypefaceUtils.ICON_ISSUE_CLOSE);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_closed));
        break;
      case "reopened":
        setText(0, TypefaceUtils.ICON_ISSUE_REOPEN);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_reopened));
        break;
      case "renamed":
        setText(0, TypefaceUtils.ICON_EDIT);
        textView(0).setTextColor(context.getResources().getColor(R.color.text_description));
        break;
      case "merged":
        message +=
            String.format(
                " commit <b>%s</b> into <tt>%s</tt> from <tt>%s</tt>",
                event.getCommitId().substring(0, 6),
                issue.getPullRequest().getBase().getRef(),
                issue.getPullRequest().getHead().getRef());
        setText(0, TypefaceUtils.ICON_MERGE);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_merged));
        break;
      case "locked":
        setText(0, TypefaceUtils.ICON_LOCK);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_lock));
        break;
      case "unlocked":
        setText(0, TypefaceUtils.ICON_KEY);
        textView(0).setTextColor(context.getResources().getColor(R.color.issue_event_lock));
        break;
    }

    message += " " + TimeUtils.getRelativeTime(event.getCreatedAt());
    setText(1, Html.fromHtml(message));
  }