Exemple #1
0
 /**
  * 部署情報を返します。
  *
  * @return
  */
 public Map<Integer, ALEipPost> getPostMap() {
   HttpServletRequest request = HttpServletRequestLocator.get();
   if (request != null) {
     // requestから取得
     @SuppressWarnings("unchecked")
     Map<Integer, ALEipPost> map = (Map<Integer, ALEipPost>) request.getAttribute(POSTS_KEY);
     if (map != null) {
       return map;
     }
   }
   // データベースから新規取得
   Map<Integer, ALEipPost> postMap = new LinkedHashMap<Integer, ALEipPost>();
   try {
     SelectQuery<EipMPost> query = Database.query(EipMPost.class);
     query.orderAscending(EipMPost.SORT_PROPERTY);
     List<EipMPost> list = query.fetchList();
     for (EipMPost record : list) {
       ALEipPost post = new ALEipPost();
       post.initField();
       post.setPostId(record.getPostId().intValue());
       post.setPostName(record.getPostName());
       post.setGroupName(record.getGroupName());
       postMap.put(record.getPostId(), post);
     }
   } catch (Exception e) {
     logger.error("[" + Database.getDomainName() + ":ALEipManager]", e);
   }
   // requestに登録
   if (request != null) {
     request.setAttribute(POSTS_KEY, postMap);
   }
   return postMap;
 }
Exemple #2
0
  /**
   * ユーザーの所属する部署の一覧を取得します。
   *
   * @param uid ユーザーID
   * @return 所属する部署リスト
   */
  public static List<AddressBookUserGroupLiteBean> getPostBeanList(int uid) {
    SelectQuery<TurbineUserGroupRole> query = Database.query(TurbineUserGroupRole.class);
    Expression exp1 =
        ExpressionFactory.matchExp(
            TurbineUserGroupRole.TURBINE_USER_PROPERTY, Integer.valueOf(uid));
    Expression exp2 =
        ExpressionFactory.greaterExp(
            TurbineUserGroupRole.TURBINE_GROUP_PROPERTY, Integer.valueOf(3));
    Expression exp3 =
        ExpressionFactory.matchExp(
            TurbineUserGroupRole.TURBINE_GROUP_PROPERTY + "." + TurbineGroup.OWNER_ID_PROPERTY,
            Integer.valueOf(1));
    query.setQualifier(exp1);
    query.andQualifier(exp2);
    query.andQualifier(exp3);

    List<TurbineUserGroupRole> list = query.fetchList();

    if (list == null || list.size() < 0) {
      return null;
    }

    List<AddressBookUserGroupLiteBean> resultList = new ArrayList<AddressBookUserGroupLiteBean>();

    TurbineUserGroupRole ugr = null;
    TurbineGroup group = null;
    AddressBookUserGroupLiteBean bean = null;
    int size = list.size();
    for (int i = 0; i < size; i++) {
      ugr = list.get(i);
      group = ugr.getTurbineGroup();
      EipMPost post = group.getEipMPost();
      bean = new AddressBookUserGroupLiteBean();
      bean.initField();
      bean.setGroupId(post.getPostId());
      bean.setName(post.getPostName());
      resultList.add(bean);
    }

    return resultList;
  }