Пример #1
0
 @Override
 public Set<UserRole> getAllRoles(String sessID)
     throws RemoteException, SQLException, SecurityException, SessionExpiredException {
   String thisDatabase = SessionManager.getInstance().getDatabaseForSession(sessID);
   TableSchema roleTable = MedSavantDatabase.UserRoleTableSchema;
   SelectQuery sq = new SelectQuery();
   sq.addFromTable(roleTable.getTable());
   sq.addColumns(
       roleTable.getDBColumn(MedSavantDatabase.UserRoleTableSchema.COLUMNNAME_OF_ID),
       roleTable.getDBColumn(MedSavantDatabase.UserRoleTableSchema.COLUMNNAME_OF_ROLENAME),
       roleTable.getDBColumn(
           MedSavantDatabase.UserRoleTableSchema.COLUMNNAME_OF_ROLE_DESCRIPTION));
   sq.setIsDistinct(true);
   ResultSet rs = null;
   try {
     rs = ConnectionController.executeQuery(sessID, sq.toString());
     Set<UserRole> roleSet = new TreeSet<UserRole>();
     while (rs.next()) {
       int roleId = rs.getInt(1);
       String roleName = rs.getString(2);
       String roleDescription = rs.getString(3);
       roleSet.add(new UserRole(roleId, roleName, roleDescription, thisDatabase));
     }
     return roleSet;
   } finally {
     if (rs != null) {
       rs.close();
     }
   }
 }