League ordering and extra league information.

This commit is contained in:
marcins78@gmail.com
2012-03-31 06:01:13 +00:00
parent 26cd25b6a7
commit c1fa7d76e0
2 changed files with 8 additions and 8 deletions

View File

@@ -8,8 +8,8 @@ import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.ResultSet; import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashSet; import java.util.ArrayList;
import java.util.Set; import java.util.List;
public class LeagueDAO { public class LeagueDAO {
private DbAccess _dbAccess; private DbAccess _dbAccess;
@@ -46,7 +46,7 @@ public class LeagueDAO {
} }
} }
public Set<League> loadActiveLeagues(int currentTime) throws SQLException, IOException { public List<League> loadActiveLeagues(int currentTime) throws SQLException, IOException {
Connection conn = _dbAccess.getDataSource().getConnection(); Connection conn = _dbAccess.getDataSource().getConnection();
try { try {
PreparedStatement statement = conn.prepareStatement("select id, name, type, class, parameters, start, end, status from league where start<=? and end>=? order by start desc"); PreparedStatement statement = conn.prepareStatement("select id, name, type, class, parameters, start, end, status from league where start<=? and end>=? order by start desc");
@@ -55,7 +55,7 @@ public class LeagueDAO {
statement.setInt(2, currentTime); statement.setInt(2, currentTime);
ResultSet rs = statement.executeQuery(); ResultSet rs = statement.executeQuery();
try { try {
Set<League> activeLeagues = new HashSet<League>(); List<League> activeLeagues = new ArrayList<League>();
while (rs.next()) { while (rs.next()) {
int id = rs.getInt(1); int id = rs.getInt(1);
String name = rs.getString(2); String name = rs.getString(2);

View File

@@ -34,7 +34,7 @@ public class LeagueService {
private Map<LeagueSerieData, List<LeagueStanding>> _leagueSerieStandings = new ConcurrentHashMap<LeagueSerieData, List<LeagueStanding>>(); private Map<LeagueSerieData, List<LeagueStanding>> _leagueSerieStandings = new ConcurrentHashMap<LeagueSerieData, List<LeagueStanding>>();
private int _activeLeaguesLoadedDate; private int _activeLeaguesLoadedDate;
private Set<League> _activeLeagues; private List<League> _activeLeagues;
public LeagueService(LeagueDAO leagueDao, LeaguePointsDAO leaguePointsDao, LeagueMatchDAO leagueMatchDao, public LeagueService(LeagueDAO leagueDao, LeaguePointsDAO leaguePointsDao, LeagueMatchDAO leagueMatchDao,
CollectionsManager collectionsManager) { CollectionsManager collectionsManager) {
@@ -65,12 +65,12 @@ public class LeagueService {
} }
} }
public Set<League> getActiveLeagues() { public List<League> getActiveLeagues() {
if (DateUtils.getCurrentDate() == _activeLeaguesLoadedDate) if (DateUtils.getCurrentDate() == _activeLeaguesLoadedDate)
return Collections.unmodifiableSet(_activeLeagues); return Collections.unmodifiableList(_activeLeagues);
else { else {
ensureLoadedCurrentLeagues(); ensureLoadedCurrentLeagues();
return Collections.unmodifiableSet(_activeLeagues); return Collections.unmodifiableList(_activeLeagues);
} }
} }