League ordering and extra league information.
This commit is contained in:
@@ -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);
|
||||||
|
|||||||
@@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user