private static void addProjectNotDupped(List<Project> target, List<Project> foundProjects) { for (Project project : foundProjects) { if (!target.contains(project)) { target.add(project); } } }
private static void collectDatum( List<Project> projects, List<Posting> postings, List<Issue> issues, List<PullRequest> pullRequests, List<Milestone> milestones, int daysAgo) { // collect all postings, issues, pullrequests and milesotnes that are contained in the projects. for (Project project : projects) { if (AccessControl.isAllowed(UserApp.currentUser(), project.asResource(), Operation.READ)) { postings.addAll(Posting.findRecentlyCreatedByDaysAgo(project, daysAgo)); issues.addAll(Issue.findRecentlyOpendIssuesByDaysAgo(project, daysAgo)); pullRequests.addAll(PullRequest.findOpendPullRequestsByDaysAgo(project, daysAgo)); milestones.addAll(Milestone.findOpenMilestones(project.id)); } } }
/** * ajax 를 이용한 사용자 검색 요청 헤더의 accept 파라미터에 application/json 값이 없으면 406 응답 응답에 포함되는 데이터 수는 * MAX_FETCH_USERS 로 제한된다 입력 파라미터 query 가 부분매칭 되는 loginId 목록을 json 형태로 응답 * * @param query 검색어 * @return */ public static Result users(String query) { if (!request().accepts("application/json")) { return status(Http.Status.NOT_ACCEPTABLE); } ExpressionList<User> el = User.find.select("loginId").where().contains("loginId", query); int total = el.findRowCount(); if (total > MAX_FETCH_USERS) { el.setMaxRows(MAX_FETCH_USERS); response().setHeader("Content-Range", "items " + MAX_FETCH_USERS + "/" + total); } List<String> loginIds = new ArrayList<>(); for (User user : el.findList()) { loginIds.add(user.loginId); } return ok(toJson(loginIds)); }