package open.dolphin.delegater;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import javax.naming.NamingException;
import open.dolphin.ejb.RemoteUserService;
import open.dolphin.infomodel.UserModel;
/**
* User 関連の Business Delegater クラス。
*
* @author Kazushi Minagawa, Digital Globe, Inc.
*/
public class UserDelegater extends BusinessDelegater {
/**
* ユーザを検索して返す。
* @param userId
* @return UserModel
*/
public UserModel getUser(String pk) throws Exception {
return getService().getUser(pk);
}
public ArrayList<UserModel> getAllUser() throws Exception {
Collection c = getService().getAllUser();
ArrayList<UserModel> ret = new ArrayList<UserModel>();
for (Iterator iter = c.iterator(); iter.hasNext(); ) {
UserModel user = (UserModel) iter.next();
ret.add(user);
}
return ret;
}
/**
* ユーザを保存する。
* @param userModel
* @return
*/
public int putUser(UserModel userModel) throws Exception {
return getService().addUser(userModel);
}
public int updateUser(UserModel userModel) throws Exception {
return getService().updateUser(userModel);
}
public int removeUser(String uid) throws Exception {
return getService().removeUser(uid);
}
public int updateFacility(UserModel user) throws Exception {
return getService().updateFacility(user);
}
private RemoteUserService getService() throws NamingException {
return (RemoteUserService)getService("RemoteUserService");
}
}