Exemplo n.º 1
0
 /**
  * Return a page
  *
  * @param page Page to display
  * @param pageSize Number of publicacao per page
  * @param sortBy publicacao titulo property used for sorting
  * @param order Sort order (either or asc or desc)
  * @param filter Filter applied on the name column
  */
 public static PagedList<Album> page(
     int page, int pageSize, String sortBy, String order, String filter) {
   return find.where()
       .ilike("titulo", "%" + filter + "%")
       .orderBy(sortBy + " " + order)
       .findPagedList(page, pageSize);
 }
Exemplo n.º 2
0
 /**
  * Finds all sellers in database and orders them by first name ascending.
  *
  * @return <code>List</code> type value of AppUser
  */
 public static List<AppUser> getAllSellersOrderedByFirstname() {
   return finder
       .where()
       .eq("user_access_level", UserAccessLevel.SELLER)
       .orderBy("firstname asc")
       .findList();
 }
Exemplo n.º 3
0
 public static <T extends UserAction> int countBy(
     Finder<Long, T> finder, ResourceType resourceType, String resourceId) {
   return finder
       .where()
       .eq("resourceType", resourceType)
       .eq("resourceId", resourceId)
       .findRowCount();
 }
Exemplo n.º 4
0
 public static int getTotalPrivateSearchPageCount(String searchTerm, String user, int pageSize) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("members.email", user)
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
Exemplo n.º 5
0
 /**
  * 주어진 {@code attach}와 내용이 같은 첨부 파일을 찾는다.
  *
  * <p>내용이 같은 첨부 파일이라고 하는 것은 이름과 파일의 내용이 같고 첨부된 리소스도 같은 것을 말한다. 구체적으로 말하면 {@link Attachment#name},
  * {@link Attachment#hash}, {@link Attachment#containerType}, {@link Attachment#containerId}가 서로
  * 같은 첨부이다.
  *
  * @param attach 이 첨부 파일과 내용이 같은 첨부 파일을 찾는다.
  * @return 발견된 첨부 파일
  */
 private static Attachment findBy(Attachment attach) {
   return find.where()
       .eq("name", attach.name)
       .eq("hash", attach.hash)
       .eq("containerType", attach.containerType)
       .eq("containerId", attach.containerId)
       .findUnique();
 }
Exemplo n.º 6
0
  /**
   * Checks if user with provided email exists in database. Should be used when using an email from
   * the cookies, to be sure that email from cookies exists in the database.
   *
   * @param email
   * @returns App_User object if user exists, and NULL if doesn't.
   */
  public static AppUser existsInDB(String email) {
    AppUser user = finder.where().eq("email", email.toString()).findUnique();

    if (user == null) {
      return null;
    } else {
      return user;
    }
  }
Exemplo n.º 7
0
 public static List<Post_thread> all(String usrInterest) {
   return find.where()
       .eq("interest", usrInterest)
       .order()
       .desc("id")
       .fetch("user")
       .setMaxRows(8)
       .findList();
 }
Exemplo n.º 8
0
 /**
  * {@code project}에서 보낸 풀리퀘 목록 중 한 페이지를 가져온다.
  *
  * <p>{@code pageNum}은 0부터 시작하고, 한 페이지당 {@code ITEMS_PER_PAGE} 만큼 가져온다.
  *
  * @param project
  * @param pageNum
  * @return
  */
 public static Page<PullRequest> findSentPullRequests(Project project, int pageNum) {
   return finder
       .where()
       .eq("fromProject", project)
       .order()
       .desc("created")
       .findPagingList(ITEMS_PER_PAGE)
       .getPage(pageNum);
 }
Exemplo n.º 9
0
 public static List<PullRequest> findByFromProjectAndBranch(
     Project fromProject, String fromBranch) {
   return finder
       .where()
       .eq("fromProject", fromProject)
       .eq("fromBranch", fromBranch)
       .or(eq("state", State.OPEN), eq("state", State.REJECTED))
       .findList();
 }
Exemplo n.º 10
0
 public static List<PullRequest> findAcceptedPullRequests(Project project) {
   return finder
       .where()
       .eq("fromProject", project)
       .or(eq("state", State.CLOSED), eq("state", State.MERGED))
       .order()
       .desc("created")
       .findList();
 }
Exemplo n.º 11
0
 public static List<PullRequest> findOpendPullRequests(Project project) {
   return finder
       .where()
       .eq("toProject", project)
       .eq("state", State.OPEN)
       .order()
       .desc("created")
       .findList();
 }
Exemplo n.º 12
0
 /**
  * Return a page of Performance
  *
  * @param page Page to display
  * @param pageSize Number of computers per page
  * @param sortBy Computer property used for sorting
  * @param order Sort order (either or asc or desc)
  * @param filter Filter applied on the name column
  */
 public static Page<Performance> page(
     int page, int pageSize, String sortBy, String order, String filter) {
   return find.where()
       .ilike("name", "%" + filter + "%")
       .orderBy(sortBy + " " + order)
       .fetch("INSERT FOREIGN KEY NAME")
       .findPagingList(pageSize)
       .getPage(page);
 }
Exemplo n.º 13
0
 public static <T extends UserAction> T findBy(
     Finder<Long, T> finder, User subject, ResourceType resourceType, String resourceId) {
   return finder
       .where()
       .eq("user.id", subject.id)
       .eq("resourceType", resourceType)
       .eq("resourceId", resourceId)
       .findUnique();
 }
Exemplo n.º 14
0
 /**
  * {@code project}에서 {@code state}에 해당하는 풀리퀘 목록 중 한 페이지를 가져온다.
  *
  * <p>{@code pageNum}은 0부터 시작하고, 한 페이지당 {@code ITEMS_PER_PAGE} 만큼 가져온다.
  *
  * @param state
  * @param project
  * @param pageNum
  * @return
  */
 public static Page<PullRequest> findPagingList(State state, Project project, int pageNum) {
   return finder
       .where()
       .eq("toProject", project)
       .eq("state", state)
       .order()
       .desc("number")
       .findPagingList(ITEMS_PER_PAGE)
       .getPage(pageNum);
 }
Exemplo n.º 15
0
 public static List<PullRequest> findRecentlyReceived(Project project, int size) {
   return finder
       .where()
       .eq("toProject", project)
       .order()
       .desc("created")
       .findPagingList(size)
       .getPage(0)
       .getList();
 }
Exemplo n.º 16
0
 public static List<Scenario> findInvolvingUserSearch(
     String searchTerm, String user, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("members.email", user)
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Exemplo n.º 17
0
 public static PullRequest findDuplicatedPullRequest(PullRequest pullRequest) {
   return finder
       .where()
       .eq("fromBranch", pullRequest.fromBranch)
       .eq("toBranch", pullRequest.toBranch)
       .eq("fromProject", pullRequest.fromProject)
       .eq("toProject", pullRequest.toProject)
       .eq("state", State.OPEN)
       .findUnique();
 }
Exemplo n.º 18
0
 /**
  * Returns the PerformanceID of given performance time
  *
  * @param performanceTime Which subversion number to find ID for
  * @return id of Performance. Creates new one if no performanceTime already existed
  */
 public static Long getPerformanceID(String performanceTime) { // Used in saveRun
   Performance performance = find.where().eq("time", performanceTime).findUnique();
   if (performance == null) { // If no Performance was found... add it and return that id
     Performance newPerformance = new Performance();
     newPerformance.time = performanceTime;
     newPerformance.save();
     return newPerformance.id;
   }
   return performance.id;
 }
Exemplo n.º 19
0
 public static int getTotalToAcceptPageCount(Date currentDate, int pageSize) {
   return find.where()
       .eq("isAccepted", false)
       .eq("isPublic", true)
       .or(
           com.avaje.ebean.Expr.lt("expirationDate", currentDate),
           com.avaje.ebean.Expr.isNull("expirationDate"))
       .findPagingList(pageSize)
       .getTotalPageCount();
 }
Exemplo n.º 20
0
 /**
  * 받은 코드 목록을 반환한다.
  *
  * <p>받은 코드는 닫혔(Closed)거나 병합(Merged)된 코드이다.
  *
  * @param project
  * @param pageNum
  * @return
  */
 public static Page<PullRequest> findClosedPagingList(Project project, int pageNum) {
   return finder
       .where()
       .eq("toProject", project)
       .or(eq("state", State.CLOSED), eq("state", State.MERGED))
       .order()
       .desc("received")
       .findPagingList(ITEMS_PER_PAGE)
       .getPage(pageNum);
 }
Exemplo n.º 21
0
 /**
  * 보내거나 받는 쪽에 {@code project} 의 {@code branch} 를 가지고 있는 pull-request 목록 조회
  *
  * <p>병합(Closed)되지 않은 모든 보낸코드를 조회한다.
  *
  * @param project
  * @param branch
  * @return
  */
 public static List<PullRequest> findRelatedPullRequests(Project project, String branch) {
   return finder
       .where()
       .or(
           Expr.and(eq("fromProject", project), eq("fromBranch", branch)),
           Expr.and(eq("toProject", project), eq("toBranch", branch)))
       .ne("state", State.CLOSED)
       .ne("state", State.MERGED)
       .findList();
 }
Exemplo n.º 22
0
 public static List<PullRequest> findOpendPullRequestsByDaysAgo(Project project, int days) {
   return finder
       .where()
       .eq("toProject", project)
       .eq("state", State.OPEN)
       .ge("created", JodaDateUtil.before(days))
       .order()
       .desc("created")
       .findList();
 }
Exemplo n.º 23
0
  /**
   * Tries to authenticate user who is trying to log in. Hashes entered password for entered email,
   * and checks if provided combination exists in the database.
   *
   * @param email
   * @param password
   * @return
   */
  public static AppUser authenticate(String email, String password) {

    AppUser user = finder.where().eq("email", email.toString()).findUnique();

    if (user != null && BCrypt.checkpw(password, user.password)) {
      return user;
    } else {
      return null;
    }
  }
Exemplo n.º 24
0
 public static int getTotalPublicAcceptedNotExpiredPageCount(int pageSize, Date currentDate) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isPublic", true)
           .eq("isAccepted", true)
           .or(
               com.avaje.ebean.Expr.lt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .findPagingList(pageSize);
   return pagingList.getTotalPageCount();
 }
  public static Set<PassageQuestionRecord> byUserAndPassage(User user, SimplePassage passage) {
    ArrayList<String> lessonQuestionIds = new ArrayList<String>(passage.questions.size());
    for (PassageQuestion question : passage.questions) {
      lessonQuestionIds.add(question.id.toString());
    }

    return find.where()
        .ne("disavowed", true)
        .eq("user_id", user.id)
        .in("passage_question_id", lessonQuestionIds)
        .findSet();
  }
Exemplo n.º 26
0
 public static List<Scenario> findToAccept(Date currentDate, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isAccepted", false)
           .eq("isPublic", true)
           .or(
               com.avaje.ebean.Expr.lt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
Exemplo n.º 27
0
  /**
   * {@code fromProject}의 {@code fromBranch}에서 보낸 가장 최근 코드보내기 요청을 찾는다.
   *
   * <p>fromProject와 toProject가 같은 수도 있다고 가정한다. {@code fromProject}가 fork 프로젝트 일때는 upstream으로 보낸
   * 코드보내기 요청을 포함하여 찾는다.
   *
   * <p>when: 코드 메뉴의 브랜치 탭에서 브랜치 목록을 보여줄 때 특정 브랜치와 관련있는 코드보내기 요청을 찾을 때 사용한다.
   *
   * @param fromProject
   * @param fromBranch
   * @return
   */
  public static PullRequest findTheLatestOneFrom(Project fromProject, String fromBranch) {
    ExpressionList<PullRequest> el =
        finder.where().eq("fromProject", fromProject).eq("fromBranch", fromBranch);

    if (fromProject.isForkedFromOrigin()) {
      el.in("toProject", fromProject, fromProject.originalProject);
    } else {
      el.eq("toProject", fromProject);
    }

    return el.order().desc("number").setMaxRows(1).findUnique();
  }
Exemplo n.º 28
0
 public static List<Scenario> findPublicAcceptedNotExpiredSearch(
     String searchTerm, Date currentDate, int pageSize, int pageNum) {
   PagingList<Scenario> pagingList =
       find.where()
           .eq("isPublic", true)
           .eq("isAccepted", true)
           .or(
               com.avaje.ebean.Expr.gt("expirationDate", currentDate),
               com.avaje.ebean.Expr.isNull("expirationDate"))
           .icontains("name", searchTerm)
           .findPagingList(pageSize);
   Page<Scenario> page = pagingList.getPage(pageNum);
   return page.getList();
 }
  public static PassageQuestionRecord byMostRecentForUser(User user, PassageQuestion question) {
    List<PassageQuestionRecord> theList =
        find.where()
            .ne("disavowed", true)
            .eq("user_id", user.id)
            .eq("passage_question_id", question.id)
            .findList();

    if (theList.size() == 0) {
      return null;
    } else {
      return theList.get(theList.size() - 1);
    }
  }
 public static PassageQuestionRecord byTimeTaken(
     User user, PassageQuestion passageQuestion, int timeTaken) {
   List<PassageQuestionRecord> theList =
       find.where()
           .ne("disavowed", true)
           .eq("user_id", user.id)
           .eq("passage_question_id", passageQuestion.id)
           .findList();
   if (theList.size() == 0) {
     return null;
   } else {
     //			if (theList.size() <= timeTaken) {
     //				timeTaken -= 1;
     //			}
     return theList.get(timeTaken);
   }
 }