1
2 package hoplugins.teamAnalyzer.manager;
3
4 import hoplugins.teamAnalyzer.dao.PlayerDataDAO;
5 import hoplugins.teamAnalyzer.vo.PlayerInfo;
6
7 import java.util.Iterator;
8 import java.util.List;
9
10
11 /***
12 * TODO Missing Class Documentation
13 *
14 * @author TODO Author Name
15 */
16 public class PlayerDataManager {
17
18
19 /*** TODO Missing Parameter Documentation */
20 public static final int AVAILABLE = 0;
21
22 /*** TODO Missing Parameter Documentation */
23 public static final int INJURED = 1;
24
25 /*** TODO Missing Parameter Documentation */
26 public static final int SUSPENDED = 2;
27
28 /*** TODO Missing Parameter Documentation */
29 public static final int SOLD = 3;
30 private static PlayerDataDAO dao = new PlayerDataDAO();
31
32
33
34 /***
35 * TODO Missing Method Documentation
36 *
37 * @param playerId TODO Missing Method Parameter Documentation
38 *
39 * @return TODO Missing Return Method Documentation
40 */
41 public static PlayerInfo getLatestPlayerInfo(int playerId) {
42 PlayerInfo info = dao.getPlayerInfo(playerId);
43
44 if (info.getPlayerId() == 0) {
45 info = dao.getPreviousPlayeInfo(playerId);
46 }
47
48 return info;
49 }
50
51 /***
52 * TODO Missing Method Documentation
53 *
54 * @param id TODO Missing Method Parameter Documentation
55 * @param week TODO Missing Method Parameter Documentation
56 * @param season TODO Missing Method Parameter Documentation
57 *
58 * @return TODO Missing Return Method Documentation
59 */
60 public static PlayerInfo getPlayerInfo(int id, int week, int season) {
61 return dao.getPlayerInfo(id, week, season);
62 }
63
64 /***
65 * TODO Missing Method Documentation
66 *
67 * @param id TODO Missing Method Parameter Documentation
68 *
69 * @return TODO Missing Return Method Documentation
70 */
71 public static PlayerInfo getPlayerInfo(int id) {
72 return dao.getPlayerInfo(id);
73 }
74
75 /***
76 * TODO Missing Method Documentation
77 *
78 * @param playerId TODO Missing Method Parameter Documentation
79 *
80 * @return TODO Missing Return Method Documentation
81 */
82 public static PlayerInfo getPreviousPlayerInfo(int playerId) {
83 return dao.getPreviousPlayeInfo(playerId);
84 }
85
86 /***
87 * TODO Missing Method Documentation
88 *
89 * @param players TODO Missing Method Parameter Documentation
90 */
91 public static void update(List players) {
92 for (Iterator iter = players.iterator(); iter.hasNext();) {
93 PlayerInfo parsedPlayer = (PlayerInfo) iter.next();
94 setPlayer(parsedPlayer);
95 }
96 }
97
98 /***
99 * TODO Missing Method Documentation
100 *
101 * @param info TODO Missing Method Parameter Documentation
102 */
103 private static void setPlayer(PlayerInfo info) {
104 if (info.getPlayerId() == 0) {
105 return;
106 }
107
108 PlayerInfo actual = dao.getPlayerInfo(info.getPlayerId());
109
110 if (actual.getPlayerId() == 0) {
111 dao.addPlayer(info);
112 } else {
113 dao.updatePlayer(info);
114 }
115 }
116 }