public List<Team> loadUserTeams(List<YahooLeague> ylList) { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> userData; Map<String, Object> results; List<Map<String, Object>> teamList; Map<String, Object> query; List<Team> teamListResults = new LinkedList<Team>(); for (YahooLeague yl : ylList) { String yql = "select * from fantasysports.teams where league_key = '" + yl.getLeague_key() + "'"; String response = yqlUitl.queryYQL(yql); try { userData = mapper.readValue(response, Map.class); query = (Map<String, Object>) userData.get("query"); // query details results = (Map<String, Object>) query.get("results"); // result details teamList = (List<Map<String, Object>>) results.get("team"); // result details for (Map map : teamList) { Team tempTeam = mapper.readValue(JacksonPojoMapper.toJson(map, false), Team.class); teamListResults.add(tempTeam); } } catch (Exception e) { Logger.getLogger(TeamService.class.getName()).log(Level.SEVERE, null, e); } } return teamListResults; }
public Roster getRoster2(String teamKey, int week) { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> userData; Map<String, Object> results; Map<String, Object> team; Map<String, Object> query; Roster rosterResults = null; String yql = "select * from fantasysports.teams.roster where team_key='" + teamKey + "' and week='" + week + "'"; String response = yqlUitl.queryYQL(yql); try { userData = mapper.readValue(response, Map.class); query = (Map<String, Object>) userData.get("query"); // query details results = (Map<String, Object>) query.get("results"); // result details team = (Map<String, Object>) results.get("team"); // result details Roster roster = mapper.readValue(JacksonPojoMapper.toJson((Map) team.get("roster"), false), Roster.class); rosterResults = roster; } catch (Exception e) { Logger.getLogger(TeamService.class.getName()).log(Level.SEVERE, null, e); } return rosterResults; }
public List<Team> loadUserTeams() { ObjectMapper mapper = new ObjectMapper(); Map<String, Object> userData; Map<String, Object> results; List<Map<String, Object>> teamList; Map<String, Object> query; List<Team> teamListResults = new LinkedList<Team>(); List<String> yqlList = new LinkedList<String>(); String yql = "select * from fantasysports.teams where game_key = 'nfl' and use_login=1"; yqlList.add(yql); yql = "select * from fantasysports.teams where game_key = '273' and use_login=1"; yqlList.add(yql); yql = "select * from fantasysports.teams where game_key = '257' and use_login=1"; yqlList.add(yql); yql = "select * from fantasysports.teams where game_key = '242' and use_login=1"; yqlList.add(yql); yql = "select * from fantasysports.teams where game_key = '222' and use_login=1"; yqlList.add(yql); yql = "select * from fantasysports.teams where game_key = '199' and use_login=1"; yqlList.add(yql); for (String ql : yqlList) { String response = yqlUitl.queryYQL(ql); try { userData = mapper.readValue(response, Map.class); query = (Map<String, Object>) userData.get("query"); // query details results = (Map<String, Object>) query.get("results"); // result details teamList = (List<Map<String, Object>>) results.get("team"); // result details for (Map map : teamList) { Team tempTeam = mapper.readValue(JacksonPojoMapper.toJson(map, false), Team.class); teamListResults.add(tempTeam); } } catch (Exception e) { Logger.getLogger(TeamService.class.getName()).log(Level.SEVERE, null, e); } } return teamListResults; // }