mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-02 18:33:54 +00:00
fixed bug 69 (When untracking a race with race column expanded, at least the default leaderboard messes up)
This commit is contained in:
1 parent
3a424d75f5
commit
0955c2fd64
7 files changed
+108
-122
No files matched your search
File mode changed.
+1
-1
@@ -199,7 +199,7 @@ public abstract class TrackedRaceImpl implements TrackedRace, CourseListener {
|
||||
|
||||
@Override
|
||||
public boolean hasStarted(TimePoint at) {
|
||||
return getStart().compareTo(at) <= 0;
|
||||
return getStart() != null && getStart().compareTo(at) <= 0;
|
||||
}
|
||||
|
||||
protected void setStartTimeReceived(TimePoint start) {
|
||||
|
||||
+1
-5
@@ -168,11 +168,7 @@ public abstract class ExpandableSortableColumn<C> extends SortableColumn<Leaderb
|
||||
final CellTable<LeaderboardRowDAO> table = getLeaderboardPanel().getLeaderboardTable();
|
||||
if (isExpanded()) {
|
||||
for (SortableColumn<LeaderboardRowDAO, ?> column : getAllVisibleChildren()) {
|
||||
int columnIndex = table.getColumnIndex(column);
|
||||
// remove only the children currently displayed
|
||||
if (columnIndex >= 0) {
|
||||
getLeaderboardPanel().removeColumn(columnIndex);
|
||||
}
|
||||
getLeaderboardPanel().removeColumn(column); // removes only the children currently displayed
|
||||
}
|
||||
// important: toggle expanded state after asking for all visible children
|
||||
setExpanded(!isExpanded());
|
||||
|
||||
+33
-17
@@ -480,9 +480,18 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
// removing the columns from the table
|
||||
// is based on column identity
|
||||
int legCount = getLeaderboard().getLegCount(getRaceName());
|
||||
for (int i = 0; i < legCount; i++) {
|
||||
LegColumn legColumn = getLegColumn(i);
|
||||
result.add(legColumn);
|
||||
if (legCount != -1) {
|
||||
for (int i = 0; i < legCount; i++) {
|
||||
LegColumn legColumn = getLegColumn(i);
|
||||
result.add(legColumn);
|
||||
}
|
||||
} else {
|
||||
// the race is no longer part of the LeaderboardDAO; consider the non-null legs in legColumns:
|
||||
for (LegColumn legColumn : legColumns) {
|
||||
if (legColumn != null) {
|
||||
result.add(legColumn);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -836,11 +845,28 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
* table} and fixes the column styles again (see {@link #addColumnStyles(int)}).
|
||||
*/
|
||||
protected void removeColumn(int columnIndex) {
|
||||
Column<LeaderboardRowDAO, ?> c = getLeaderboardTable().getColumn(columnIndex);
|
||||
if (c instanceof ExpandableSortableColumn<?>) {
|
||||
ExpandableSortableColumn<?> expandableColumn = (ExpandableSortableColumn<?>) c;
|
||||
if (expandableColumn.isExpanded()) {
|
||||
// remove expanded child columns from the leaderboard...
|
||||
expandableColumn.toggleExpansion();
|
||||
// them remember that column c was expanded:
|
||||
expandableColumn.setExpanded(true);
|
||||
}
|
||||
}
|
||||
removeColumnStyles(/* startColumn */columnIndex);
|
||||
getLeaderboardTable().removeColumn(columnIndex);
|
||||
addColumnStyles(/* startColumn */columnIndex);
|
||||
}
|
||||
|
||||
protected void removeColumn(Column<LeaderboardRowDAO, ?> c) {
|
||||
int columnIndex = getLeaderboardTable().getColumnIndex(c);
|
||||
if (columnIndex != -1) {
|
||||
removeColumn(columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private void loadCompleteLeaderboard(Date date) {
|
||||
getSailingService().getLeaderboardByName(getLeaderboardName(), date,
|
||||
/* namesOfRacesForWhichToLoadLegDetails */getNamesOfExpandedRaces(), new AsyncCallback<LeaderboardDAO>() {
|
||||
@@ -988,14 +1014,6 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
}
|
||||
}
|
||||
|
||||
// protected RaceColumn<?> createRaceColumn(Map.Entry<String, Pair<Boolean,
|
||||
// Boolean>> raceNameAndMedalRaceAndTracked) {
|
||||
// return new TextRaceColumn(raceNameAndMedalRaceAndTracked.getKey(),
|
||||
// raceNameAndMedalRaceAndTracked.getValue().getA(),
|
||||
// raceNameAndMedalRaceAndTracked.getValue().getB(),
|
||||
// RACE_COLUMN_HEADER_STYLE, RACE_COLUMN_STYLE);
|
||||
// }
|
||||
|
||||
protected RaceColumn<?> createRaceColumn(String raceName, boolean isMedalRace, boolean isTracked) {
|
||||
return new TextRaceColumn(raceName, isMedalRace, isTracked, RACE_COLUMN_HEADER_STYLE, RACE_COLUMN_STYLE);
|
||||
}
|
||||
@@ -1004,18 +1022,16 @@ public class LeaderboardPanel extends FormPanel implements TimeListener, PlaySta
|
||||
List<Column<LeaderboardRowDAO, ?>> columnsToRemove = new ArrayList<Column<LeaderboardRowDAO, ?>>();
|
||||
for (int i = 0; i < getLeaderboardTable().getColumnCount(); i++) {
|
||||
Column<LeaderboardRowDAO, ?> c = getLeaderboardTable().getColumn(i);
|
||||
/*
|
||||
* if (c instanceof RaceColumn && (leaderboard == null ||
|
||||
* !leaderboard.raceNamesAndMedalRaceAndTracked.keySet().contains( ((RaceColumn<?>) c).getRaceName()))) {
|
||||
* columnsToRemove.add(c); }
|
||||
*/
|
||||
if (c instanceof RaceColumn
|
||||
&& (leaderboard == null || !leaderboard.raceListContains(((RaceColumn<?>) c).getRaceName()))) {
|
||||
columnsToRemove.add(c);
|
||||
}
|
||||
}
|
||||
// Tricky issue: if the race column is currently expanded, we can't know anymore how many detail columns
|
||||
// there are because the updated LeaderboardDAO object doesn't contain the race anymore. We have to
|
||||
// collapse and remove all LegColumns following the RaceColumn
|
||||
for (Column<LeaderboardRowDAO, ?> c : columnsToRemove) {
|
||||
getLeaderboardTable().removeColumn(c);
|
||||
removeColumn(c);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+72
-97
@@ -20,7 +20,6 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
public class LeaderboardDAO implements IsSerializable {
|
||||
public String name;
|
||||
public List<CompetitorDAO> competitors;
|
||||
//public LinkedHashMap<String, Pair<Boolean, Boolean>> raceNamesAndMedalRaceAndTracked;
|
||||
private List<String> raceNames;
|
||||
private Map<String, Boolean> racesMedalRace;
|
||||
private Map<String, Boolean> racesTracked;
|
||||
@@ -77,17 +76,11 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
*/
|
||||
public boolean scoredInMedalRace(CompetitorDAO competitor) {
|
||||
LeaderboardRowDAO row = rows.get(competitor);
|
||||
/*
|
||||
for (Map.Entry<String, Pair<Boolean, Boolean>> raceNameAndMedalRace : raceNamesAndMedalRaceAndTracked.entrySet()) {
|
||||
if (raceNameAndMedalRace.getValue().getA() && row.fieldsByRaceName.get(raceNameAndMedalRace.getKey()).totalPoints > 0) {
|
||||
for (String race : raceNames) {
|
||||
if (raceIsMedalRace(race) && row.fieldsByRaceName.get(race).totalPoints > 0) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (String race : raceNames){
|
||||
if (raceIsMedalRace(race) && row.fieldsByRaceName.get(race).totalPoints > 0)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -103,35 +96,45 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
@Override
|
||||
public int compare(LeaderboardRowDAO o1, LeaderboardRowDAO o2) {
|
||||
int result;
|
||||
if (scoredInMedalRace(o1.competitor)) {
|
||||
if (scoredInMedalRace(o2.competitor)) {
|
||||
// both scored in medal race
|
||||
result = getTotalPoints(o1) - getTotalPoints(o2);
|
||||
// in case of tie, medal race points decide:
|
||||
if (result == 0) {
|
||||
result = getMedalRaceScore(o1.competitor) - getMedalRaceScore(o2.competitor);
|
||||
}
|
||||
} else {
|
||||
// only o1 scored in medal race, so o1 scores better = "less"
|
||||
result = -1;
|
||||
}
|
||||
if (o1 == null && o2 == null) {
|
||||
result = 0;
|
||||
} else if (o1 == null) {
|
||||
result = -1;
|
||||
} else if (o2 == null) {
|
||||
result = 1;
|
||||
} else {
|
||||
if (scoredInMedalRace(o2.competitor)) {
|
||||
// only o2 scored in medal race, so o2 scores better, o1 scores worse = "greater"
|
||||
result = 1;
|
||||
} else {
|
||||
// neither one scored in any medal race
|
||||
result = getTotalPoints(o1) - getTotalPoints(o2);
|
||||
// Now if both have equal points, count races won.
|
||||
if (result == 0) {
|
||||
result = getNumberOfRacesWon(o2.competitor) - getNumberOfRacesWon(o1.competitor);
|
||||
if (scoredInMedalRace(o1.competitor)) {
|
||||
if (scoredInMedalRace(o2.competitor)) {
|
||||
// both scored in medal race
|
||||
result = getTotalPoints(o1) - getTotalPoints(o2);
|
||||
// in case of tie, medal race points decide:
|
||||
if (result == 0) {
|
||||
result = getMedalRaceScore(o1.competitor) - getMedalRaceScore(o2.competitor);
|
||||
}
|
||||
} else {
|
||||
// only o1 scored in medal race, so o1 scores better = "less"
|
||||
result = -1;
|
||||
}
|
||||
// If number of races won is still equal, use rank in last race where at least one of the two competitors was assigned a score
|
||||
if (result == 0) {
|
||||
String nameOfLastRaceSoFar = getNameOfLastRaceSoFar(o1.competitor, o2.competitor);
|
||||
int netPoints1 = getNetPoints(o1.competitor, nameOfLastRaceSoFar);
|
||||
int netPoints2 = getNetPoints(o2.competitor, nameOfLastRaceSoFar);
|
||||
result = netPoints1==0 ? netPoints2==0 ? 0 : -1 : netPoints2==0 ? 1 : netPoints1-netPoints2;
|
||||
} else {
|
||||
if (scoredInMedalRace(o2.competitor)) {
|
||||
// only o2 scored in medal race, so o2 scores better, o1 scores worse = "greater"
|
||||
result = 1;
|
||||
} else {
|
||||
// neither one scored in any medal race
|
||||
result = getTotalPoints(o1) - getTotalPoints(o2);
|
||||
// Now if both have equal points, count races won.
|
||||
if (result == 0) {
|
||||
result = getNumberOfRacesWon(o2.competitor) - getNumberOfRacesWon(o1.competitor);
|
||||
}
|
||||
// If number of races won is still equal, use rank in last race where at least one of the two
|
||||
// competitors was assigned a score
|
||||
if (result == 0) {
|
||||
String nameOfLastRaceSoFar = getNameOfLastRaceSoFar(o1.competitor, o2.competitor);
|
||||
int netPoints1 = getNetPoints(o1.competitor, nameOfLastRaceSoFar);
|
||||
int netPoints2 = getNetPoints(o2.competitor, nameOfLastRaceSoFar);
|
||||
result = netPoints1 == 0 ? netPoints2 == 0 ? 0 : -1 : netPoints2 == 0 ? 1 : netPoints1
|
||||
- netPoints2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -186,17 +189,11 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
private int getMedalRaceScore(CompetitorDAO competitor) {
|
||||
int result = 0;
|
||||
LeaderboardRowDAO row = rows.get(competitor);
|
||||
/*
|
||||
for (Map.Entry<String, Pair<Boolean, Boolean>> raceNameAndMedalRace : raceNamesAndMedalRaceAndTracked.entrySet()) {
|
||||
if (raceNameAndMedalRace.getValue().getA() && row.fieldsByRaceName.containsKey(raceNameAndMedalRace.getKey())) {
|
||||
result += row.fieldsByRaceName.get(raceNameAndMedalRace.getKey()).netPoints;
|
||||
for (String race : raceNames) {
|
||||
if (raceIsMedalRace(race) && row.fieldsByRaceName.containsKey(race)) {
|
||||
result += row.fieldsByRaceName.get(race).netPoints;
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (String race : raceNames){
|
||||
if (raceIsMedalRace(race) && row.fieldsByRaceName.containsKey(race))
|
||||
result += row.fieldsByRaceName.get(race).netPoints;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -218,21 +215,8 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
*/
|
||||
private String getNameOfLastRaceSoFar(CompetitorDAO c1, CompetitorDAO c2) {
|
||||
String nameOfLastRaceSoFar = null;
|
||||
/*
|
||||
for (String raceName : raceNamesAndMedalRaceAndTracked.keySet()) {
|
||||
for (String race : raceNames) {
|
||||
for (LeaderboardRowDAO row : rows.values()) {
|
||||
if (row.competitor.equals(c1) || row.competitor.equals(c2)) {
|
||||
LeaderboardEntryDAO leaderboardEntryDAO = row.fieldsByRaceName.get(raceName);
|
||||
if (leaderboardEntryDAO != null && leaderboardEntryDAO.netPoints != 0) {
|
||||
nameOfLastRaceSoFar = raceName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (String race : raceNames){
|
||||
for (LeaderboardRowDAO row : rows.values()) {
|
||||
if (row.competitor.equals(c1) || row.competitor.equals(c2)) {
|
||||
LeaderboardEntryDAO leaderboardEntryDAO = row.fieldsByRaceName.get(race);
|
||||
if (leaderboardEntryDAO != null && leaderboardEntryDAO.netPoints != 0) {
|
||||
@@ -249,20 +233,12 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
int result = 0;
|
||||
LeaderboardRowDAO row = rows.get(competitor);
|
||||
if (row != null) {
|
||||
/*
|
||||
for (String raceName : raceNamesAndMedalRaceAndTracked.keySet()) {
|
||||
LeaderboardEntryDAO field = row.fieldsByRaceName.get(raceName);
|
||||
for (String race : raceNames) {
|
||||
LeaderboardEntryDAO field = row.fieldsByRaceName.get(race);
|
||||
if (field != null && field.netPoints == 1) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (String race : raceNames){
|
||||
LeaderboardEntryDAO field = row.fieldsByRaceName.get(race);
|
||||
if (field != null && field.netPoints == 1) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -320,38 +296,37 @@ public class LeaderboardDAO implements IsSerializable {
|
||||
return raceNames;
|
||||
}
|
||||
|
||||
public boolean raceListContains(String raceName){
|
||||
if (getRaceIdByName(raceName) == -1)
|
||||
return false;
|
||||
return true;
|
||||
public boolean raceListContains(String raceName) {
|
||||
return getRaceIdByName(raceName) != -1;
|
||||
}
|
||||
|
||||
public int getRaceIdByName(String raceName){
|
||||
for (int i = 0; i < raceNames.size(); i++) {
|
||||
if(raceNames.get(i).equals(raceName))
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
public int getRaceIdByName(String raceName) {
|
||||
for (int i = 0; i < raceNames.size(); i++) {
|
||||
if (raceNames.get(i).equals(raceName)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void moveRaceUp(String raceName){
|
||||
int index = getRaceIdByName(raceName);
|
||||
index--;
|
||||
if (index >= 0){
|
||||
raceNames.remove(index+1);
|
||||
raceNames.add(index, raceName);
|
||||
}
|
||||
|
||||
public void moveRaceUp(String raceName) {
|
||||
int index = getRaceIdByName(raceName);
|
||||
index--;
|
||||
if (index >= 0) {
|
||||
raceNames.remove(index + 1);
|
||||
raceNames.add(index, raceName);
|
||||
}
|
||||
}
|
||||
|
||||
public void moveRaceDown(String raceName){
|
||||
int index = getRaceIdByName(raceName);
|
||||
if (index == -1)
|
||||
return;
|
||||
index++;
|
||||
if (index < raceNames.size()){
|
||||
raceNames.remove(index-1);
|
||||
raceNames.add(index, raceName);
|
||||
}
|
||||
|
||||
public void moveRaceDown(String raceName) {
|
||||
int index = getRaceIdByName(raceName);
|
||||
if (index != -1) {
|
||||
index++;
|
||||
if (index < raceNames.size()) {
|
||||
raceNames.remove(index - 1);
|
||||
raceNames.add(index, raceName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setIsMedalRace(String raceName, boolean isMedalRace){
|
||||
|
||||
-1
@@ -1,3 +1,2 @@
|
||||
# Module com.sap.sailing.gwt.ui.AdminConsole
|
||||
# RPC service class, partial path of RPC policy file
|
||||
com.sap.sailing.gwt.ui.client.SailingService, 0148445E03B6030B90BCBC2A759DFD15.gwt.rpc
|
||||
@@ -24,5 +24,5 @@
|
||||
<booleanAttribute key="tracing" value="false"/>
|
||||
<booleanAttribute key="useCustomFeatures" value="false"/>
|
||||
<booleanAttribute key="useDefaultConfigArea" value="false"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils.test@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.declination.test@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.swisstimingadapter.test@default:default,com.sap.sailing.domain.swisstimingadapter@default:default,com.sap.sailing.domain.test@default:default,com.sap.sailing.domain.tractracadapter@default:default,com.sap.sailing.domain@default:default,com.sap.sailing.expeditionconnector.test@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.gwt.ui@default:default,com.sap.sailing.mongodb.test@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.server.test@default:default,com.sap.sailing.server@default:default,com.sap.sailing.udpconnector@default:default,com.sap.ui.phoenix.resource-osgi@default:false,com.sap.ui.phoenix.resource-servlet@default:default,com.tractrac.clientmodule@default:default,com.tractrac.resultapi@default:default,org.json.simple@default:default"/>
|
||||
<stringAttribute key="workspace_bundles" value="com.google.gwt.osgi@default:default,com.googlecode.java-diff-utils.test@default:default,com.googlecode.java-diff-utils@default:default,com.mongodb.driver@default:default,com.sap.sailing.declination.test@default:default,com.sap.sailing.declination@default:default,com.sap.sailing.domain.persistence@default:default,com.sap.sailing.domain.swisstimingadapter.persistence@default:default,com.sap.sailing.domain.swisstimingadapter.test@default:default,com.sap.sailing.domain.swisstimingadapter@default:default,com.sap.sailing.domain.test@default:default,com.sap.sailing.domain.tractracadapter.persistence@default:default,com.sap.sailing.domain.tractracadapter@default:default,com.sap.sailing.domain@default:default,com.sap.sailing.expeditionconnector.test@default:default,com.sap.sailing.expeditionconnector@default:default,com.sap.sailing.gwt.ui.test@default:default,com.sap.sailing.gwt.ui@default:default,com.sap.sailing.httpservicetracker@default:default,com.sap.sailing.mongodb.test@default:default,com.sap.sailing.mongodb@default:default,com.sap.sailing.server.test@default:default,com.sap.sailing.server@default:default,com.sap.sailing.udpconnector@default:default,com.sap.sailing.xcelsiusadapter@default:default,com.sap.ui.phoenix.resource-osgi@default:false,com.sap.ui.phoenix.resource-servlet@default:default,com.tractrac.clientmodule@default:default,com.tractrac.resultapi@default:default,org.json.simple@default:default"/>
|
||||
</launchConfiguration>
|
||||
Reference in new issue
Block a user