aipoの機能としてよく使われる、あるグループに属するALEipUserオブジェクトを得る方法です。
private List<ALEipUser> userList = null; target_group_name = getTargetGroupName(rundata, context); if (target_group_name.equals("only")) { target_group_name = "all"; } if ((target_group_name != null) && (!target_group_name.equals("")) && (!target_group_name.equals("all"))) { userList = ALEipUtils.getUsers(target_group_name); } else { userList = ALEipUtils.getUsers("LoginUser"); }
ALEipUtils.getUsersメソッドはgroupnameを引数として指定して、 sqlを実行してALEipUserオブジェクトの配列を得ています。
public class ALEipUtils { public static List<ALEipUser> getUsers(String groupname) { List<ALEipUser> list = new ArrayList<ALEipUser>(); // SQLの作成 StringBuffer statement = new StringBuffer(); statement.append("SELECT DISTINCT "); statement .append(" B.USER_ID, B.LOGIN_NAME, B.FIRST_NAME, B.LAST_NAME, D.POSITION "); statement.append("FROM turbine_user_group_role as A "); statement.append("LEFT JOIN turbine_user as B "); statement.append(" on A.USER_ID = B.USER_ID "); statement.append("LEFT JOIN turbine_group as C "); statement.append(" on A.GROUP_ID = C.GROUP_ID "); statement.append("LEFT JOIN eip_m_user_position as D "); statement.append(" on A.USER_ID = D.USER_ID "); statement.append("WHERE B.USER_ID > 3 AND B.DISABLED = 'F'"); statement.append(" AND C.GROUP_NAME = #bind($groupName) "); statement.append("ORDER BY D.POSITION"); String query = statement.toString(); try { List<TurbineUser> list2 = Database .sql(TurbineUser.class, query) .param("groupName", groupname) .fetchList(); for (TurbineUser tuser : list2) { list.add(getALEipUser(tuser)); } } catch (Throwable t) { logger.error("ALEipUtils.getUsers", t); } return list; } }