Exemple #1
0
  /**
   * 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, name").where().disjunction();
    el.icontains("loginId", query);
    el.icontains("name", query);
    el.endJunction();

    int total = el.findRowCount();
    if (total > MAX_FETCH_USERS) {
      el.setMaxRows(MAX_FETCH_USERS);
      response().setHeader("Content-Range", "items " + MAX_FETCH_USERS + "/" + total);
    }

    List<Map<String, String>> users = new ArrayList<>();
    for (User user : el.findList()) {
      StringBuilder sb = new StringBuilder();
      sb.append(String.format("<img class='mention_image' src='%s'>", user.avatarUrl()));
      sb.append(String.format("<b class='mention_name'>%s</b>", user.name));
      sb.append(String.format("<span class='mention_username'> @%s</span>", user.loginId));

      Map<String, String> userMap = new HashMap<>();
      userMap.put("info", sb.toString());
      userMap.put("loginId", user.loginId);
      users.add(userMap);
    }

    return ok(toJson(users));
  }
Exemple #2
0
  /** finds all patients with a country filter */
  public static List<? extends IPatient> findPatients(
      IRepository<IPatient> patientRepository, String country) {

    ExpressionList<Patient> patientExpressionList =
        QueryProvider.getPatientQuery()
            .select("*")
            .fetch("patientEncounters")
            .fetch("patientEncounters.missionTrip")
            .fetch("patientEncounters.missionTrip.missionCity")
            .fetch("patientEncounters.missionTrip.missionCity.missionCountry")
            .where()
            .eq("patientEncounters.missionTrip.missionCity.missionCountry.name", country);

    return patientExpressionList.findList();
  }
Exemple #3
0
  /**
   * 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));
  }
Exemple #4
0
 /**
  * This method filters permission refusals by name and returns a list of filtered
  * PermissionRefusal objects.
  *
  * @param name
  * @return
  */
 public static List<PermissionRefusal> filterByName(String name) {
   List<PermissionRefusal> res = new ArrayList<PermissionRefusal>();
   ExpressionList<PermissionRefusal> ll = find.where().icontains(Const.NAME, name);
   res = ll.findList();
   return res;
 }
Exemple #5
0
 /**
  * This method filters roles by name and returns a list of filtered Role objects.
  *
  * @param name
  * @return
  */
 public static List<Role> filterByName(String name) {
   List<Role> res = new ArrayList<Role>();
   ExpressionList<Role> ll = find.where().icontains("name", name);
   res = ll.findList();
   return res;
 }