예제 #1
0
  /**
   * 프로젝트 제한을 두지 않고 전체 이슈를 대상으로 검색할 때 사용한다.
   *
   * @return ExpressionList<Issue>
   */
  public ExpressionList<Issue> asExpressionList() {
    ExpressionList<Issue> el = Issue.finder.where();

    if (assigneeId != null) {
      if (assigneeId.equals(User.anonymous.id)) {
        el.isNull("assignee");
      } else {
        el.eq("assignee.user.id", assigneeId);
      }
    }

    if (authorId != null) {
      el.eq("authorId", authorId);
    }

    if (StringUtils.isNotBlank(filter)) {
      Junction<Issue> junction = el.disjunction();
      junction.icontains("title", filter).icontains("body", filter);
      List<Object> ids = Issue.finder.where().icontains("comments.contents", filter).findIds();
      if (!ids.isEmpty()) {
        junction.idIn(ids);
      }
      junction.endJunction();
    }

    if (commentedCheck) {
      el.ge("numOfComments", AbstractPosting.NUMBER_OF_ONE_MORE_COMMENTS);
    }

    State st = State.getValue(state);
    if (st.equals(State.OPEN) || st.equals(State.CLOSED)) {
      el.eq("state", st);
    }

    if (orderBy != null) {
      el.orderBy(orderBy + " " + orderDir);
    }

    return el;
  }
예제 #2
0
  /**
   * 특정 프로젝트를 대상으로 검색 표현식을 만든다.
   *
   * @return ExpressionList<Issue>
   */
  public ExpressionList<Issue> asExpressionList(Project project) {
    ExpressionList<Issue> el = Issue.finder.where();
    if (project != null) {
      el.eq("project.id", project.id);
    }
    if (StringUtils.isNotBlank(filter)) {
      Junction<Issue> junction = el.disjunction();
      junction.icontains("title", filter).icontains("body", filter);
      List<Object> ids = null;
      if (project == null) {
        ids = Issue.finder.where().icontains("comments.contents", filter).findIds();
      } else {
        ids =
            Issue.finder
                .where()
                .eq("project.id", project.id)
                .icontains("comments.contents", filter)
                .findIds();
      }
      if (!ids.isEmpty()) {
        junction.idIn(ids);
      }
      junction.endJunction();
    }

    if (authorId != null) {
      if (authorId.equals(User.anonymous.id)) {
        el.isNull("authorId");
      } else {
        el.eq("authorId", authorId);
      }
    }

    if (assigneeId != null) {
      if (assigneeId.equals(User.anonymous.id)) {
        el.isNull("assignee");
      } else {
        el.eq("assignee.user.id", assigneeId);
        el.eq("assignee.project.id", project.id);
      }
    }

    if (milestoneId != null) {
      if (milestoneId.equals(Milestone.NULL_MILESTONE_ID)) {
        el.isNull("milestone");
      } else {
        el.eq("milestone.id", milestoneId);
      }
    }

    if (commentedCheck) {
      el.ge("numOfComments", AbstractPosting.NUMBER_OF_ONE_MORE_COMMENTS);
    }

    State st = State.getValue(state);
    if (st.equals(State.OPEN) || st.equals(State.CLOSED)) {
      el.eq("state", st);
    }

    if (CollectionUtils.isNotEmpty(labelIds)) {
      el.add(LabelSearchUtil.createLabelSearchExpression(el.query(), labelIds));
    }

    if (orderBy != null) {
      el.orderBy(orderBy + " " + orderDir);
    }

    return el;
  }