mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 05:11:04 +00:00
assembling result object in official score import dialog; implemented bulk score correction update service
This commit is contained in:
1 parent
a1a7b1dbe9
commit
718d0be68f
8 files changed
+132
-52
No files matched your search
+3
@@ -18,6 +18,7 @@ import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.impl.Util.Triple;
|
||||
import com.sap.sailing.gwt.ui.shared.BulkScoreCorrectionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CourseDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
@@ -231,4 +232,6 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
RegattaScoreCorrectionDTO getScoreCorrections(String scoreCorrectionProviderName, String eventName, String boatClassName,
|
||||
Date timePointWhenResultPublished) throws Exception;
|
||||
|
||||
void updateLeaderboardScoreCorrectionsAndMaxPointsReasons(BulkScoreCorrectionDTO updates) throws NoWindException;
|
||||
}
|
||||
+6
-2
@@ -16,6 +16,7 @@ import com.sap.sailing.domain.common.RaceIdentifier;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.impl.Util.Triple;
|
||||
import com.sap.sailing.gwt.ui.shared.BulkScoreCorrectionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CourseDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
@@ -212,14 +213,17 @@ public interface SailingServiceAsync {
|
||||
void disconnectLeaderboardColumnFromTrackedRace(String leaderboardName, String raceColumnName, String fleetName,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
void updateLeaderboardCarryValue(String leaderboardName, String competitorID, Integer carriedPoints, AsyncCallback<Void> callback);
|
||||
void updateLeaderboardCarryValue(String leaderboardName, String competitorIdAsString, Integer carriedPoints, AsyncCallback<Void> callback);
|
||||
|
||||
void updateLeaderboardMaxPointsReason(String leaderboardName, String competitorID, String raceColumnName,
|
||||
void updateLeaderboardMaxPointsReason(String leaderboardName, String competitorIdAsString, String raceColumnName,
|
||||
MaxPointsReason maxPointsReason, Date date, AsyncCallback<Pair<Integer, Integer>> asyncCallback);
|
||||
|
||||
void updateLeaderboardScoreCorrection(String leaderboardName, String competitorIdAsString, String columnName,
|
||||
Integer correctedScore, Date date, AsyncCallback<Triple<Integer, Integer, Boolean>> asyncCallback);
|
||||
|
||||
void updateLeaderboardScoreCorrectionsAndMaxPointsReasons(BulkScoreCorrectionDTO updates,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
void updateCompetitorDisplayNameInLeaderboard(String leaderboardName, String competitorID, String displayName,
|
||||
AsyncCallback<Void> callback);
|
||||
|
||||
|
||||
+8
-8
@@ -199,10 +199,10 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
|
||||
|
||||
private class MaxPointsDropDownCellProvider extends AbstractRowUpdateWhiteboardProducerThatHasCell<LeaderboardRowDTO, String> {
|
||||
private final SelectionCell dropDownCell;
|
||||
private final String raceName;
|
||||
private final String raceColumnName;
|
||||
|
||||
public MaxPointsDropDownCellProvider(String raceName) {
|
||||
this.raceName = raceName;
|
||||
public MaxPointsDropDownCellProvider(String raceColumnName) {
|
||||
this.raceColumnName = raceColumnName;
|
||||
List<String> selectionCellContents = new ArrayList<String>();
|
||||
selectionCellContents.add(""); // represents "no" max points reason
|
||||
for (MaxPointsReason maxPointReason : MaxPointsReason.values()) {
|
||||
@@ -225,7 +225,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
|
||||
EditableLeaderboardPanel.this.getData());
|
||||
getWhiteboardOwner().whiteboardProduced(whiteboard);
|
||||
getSailingService().updateLeaderboardMaxPointsReason(getLeaderboardName(), row.competitor.id,
|
||||
raceName, value == null || value.trim().length() == 0 ? null : MaxPointsReason.valueOf(value.trim()),
|
||||
raceColumnName, value == null || value.trim().length() == 0 ? null : MaxPointsReason.valueOf(value.trim()),
|
||||
getLeaderboardDisplayDate(), new AsyncCallback<Pair<Integer, Integer>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
@@ -237,10 +237,10 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Pair<Integer, Integer> newNetAndTotalPoints) {
|
||||
row.fieldsByRaceColumnName.get(raceName).reasonForMaxPoints = value == null
|
||||
row.fieldsByRaceColumnName.get(raceColumnName).reasonForMaxPoints = value == null
|
||||
|| value.length() == 0 ? null : MaxPointsReason.valueOf(value.trim());
|
||||
row.fieldsByRaceColumnName.get(raceName).netPoints = newNetAndTotalPoints.getA();
|
||||
row.fieldsByRaceColumnName.get(raceName).totalPoints = newNetAndTotalPoints.getB();
|
||||
row.fieldsByRaceColumnName.get(raceColumnName).netPoints = newNetAndTotalPoints.getA();
|
||||
row.fieldsByRaceColumnName.get(raceColumnName).totalPoints = newNetAndTotalPoints.getB();
|
||||
getCell().setViewData(row, null); // ensure that getValue() is called again
|
||||
whiteboard.setObjectWithWhichToUpdateRow(row);
|
||||
}
|
||||
@@ -251,7 +251,7 @@ public class EditableLeaderboardPanel extends LeaderboardPanel {
|
||||
|
||||
@Override
|
||||
public String getValue(LeaderboardRowDTO object) {
|
||||
LeaderboardEntryDTO leaderboardEntryDTO = object.fieldsByRaceColumnName.get(raceName);
|
||||
LeaderboardEntryDTO leaderboardEntryDTO = object.fieldsByRaceColumnName.get(raceColumnName);
|
||||
MaxPointsReason reasonForMaxPoints = null;
|
||||
if (leaderboardEntryDTO != null) {
|
||||
reasonForMaxPoints = leaderboardEntryDTO.reasonForMaxPoints;
|
||||
|
||||
+36
-37
@@ -24,6 +24,7 @@ import com.sap.sailing.gwt.ui.client.DataEntryDialog;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.shared.BulkScoreCorrectionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardEntryDTO;
|
||||
@@ -32,7 +33,7 @@ import com.sap.sailing.gwt.ui.shared.RaceColumnDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO.ScoreCorrectionEntryDTO;
|
||||
|
||||
public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<ScoreCorrectionsApplicationInstructions> {
|
||||
public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<BulkScoreCorrectionDTO> {
|
||||
private static final RegExp p = RegExp.compile("^([A-Z][A-Z][A-Z])[^0-9]*([0-9]*)$");
|
||||
|
||||
private final LeaderboardDTO leaderboard;
|
||||
@@ -97,20 +98,21 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<ScoreCo
|
||||
}
|
||||
|
||||
private void fillRaceNameOrNumberChoosers() {
|
||||
final Set<String> entries = regattaScoreCorrection.getScoreCorrectionsByRaceNameOrNumber().keySet();
|
||||
for (RaceColumnDTO raceColumn : leaderboard.getRaceList()) {
|
||||
ListBox listbox = createRaceNameOrNumberListBox(/* select */ raceColumnToOfficialRaceNameOrNumber.get(raceColumn));
|
||||
ListBox listbox = createListBoxWithGridUpdateChangeHandler(entries, /* select */ raceColumnToOfficialRaceNameOrNumber.get(raceColumn));
|
||||
raceNameOrNumberChoosers.put(raceColumn, listbox);
|
||||
}
|
||||
}
|
||||
|
||||
private ListBox createRaceNameOrNumberListBox(String selectedItem) {
|
||||
private ListBox createListBoxWithGridUpdateChangeHandler(Set<String> entries, String selectedItem) {
|
||||
ListBox result = createListBox(/* isMultipleSelect */ false);
|
||||
result.addItem("");
|
||||
int i=1;
|
||||
int selectionIndex = -1;
|
||||
for (String raceNameOrNumber : regattaScoreCorrection.getScoreCorrectionsByRaceNameOrNumber().keySet()) {
|
||||
result.addItem(raceNameOrNumber);
|
||||
if (selectedItem != null && selectedItem.equals(raceNameOrNumber)) {
|
||||
for (String entry : entries) {
|
||||
result.addItem(entry);
|
||||
if (selectedItem != null && selectedItem.equals(entry)) {
|
||||
selectionIndex = i;
|
||||
}
|
||||
i++;
|
||||
@@ -127,32 +129,10 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<ScoreCo
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a list box with all official sail IDs and a leading empty string representing "no mapping"
|
||||
*
|
||||
* @param selectedItem which item in the list to select; if <code>null</code>, no selection will be performed
|
||||
*/
|
||||
private ListBox createOfficialSailIDListBox(String selectedItem) {
|
||||
ListBox result = createListBox(/* isMultipleSelect */ false);
|
||||
result.addItem("");
|
||||
int i=1;
|
||||
int selectionIndex = -1;
|
||||
for (String officialSailID : allOfficialRaceIDs) {
|
||||
result.addItem(officialSailID);
|
||||
if (selectedItem != null && selectedItem.equals(officialSailID)) {
|
||||
selectionIndex = i;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
if (selectionIndex != -1) {
|
||||
result.setSelectedIndex(selectionIndex);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void fillOfficialSailIDChoosers() {
|
||||
for (CompetitorDTO competitor : leaderboard.competitors) {
|
||||
ListBox listbox = createOfficialSailIDListBox(/* selection */ defaultOfficialSailIDsForCompetitors.get(competitor));
|
||||
ListBox listbox = createListBoxWithGridUpdateChangeHandler(allOfficialRaceIDs, /* selection */
|
||||
defaultOfficialSailIDsForCompetitors.get(competitor));
|
||||
officialSailIDChoosers.put(competitor, listbox);
|
||||
}
|
||||
}
|
||||
@@ -223,9 +203,25 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<ScoreCo
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ScoreCorrectionsApplicationInstructions getResult() {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
protected BulkScoreCorrectionDTO getResult() {
|
||||
BulkScoreCorrectionDTO result = new BulkScoreCorrectionDTO();
|
||||
for (CompetitorDTO competitor : leaderboard.competitors) {
|
||||
for (RaceColumnDTO raceColumn : leaderboard.getRaceList()) {
|
||||
Pair<CompetitorDTO, RaceColumnDTO> key = new Pair<CompetitorDTO, RaceColumnDTO>(competitor, raceColumn);
|
||||
CheckBox cellCheckbox = cellCheckboxes.get(key);
|
||||
if (cellCheckbox.getValue()) {
|
||||
// apply the score correction of the cell:
|
||||
String raceNameOrNumber = getSelectedString(raceNameOrNumberChoosers, raceColumn);
|
||||
String officialSailID = getSelectedString(officialSailIDChoosers, competitor);
|
||||
ScoreCorrectionEntryDTO officialCorrectionEntry =
|
||||
regattaScoreCorrection.getScoreCorrectionsByRaceNameOrNumber()
|
||||
.get(raceNameOrNumber).get(officialSailID);
|
||||
result.addMaxPointsReasonUpdate(competitor, raceColumn, officialCorrectionEntry.getMaxPointsReason());
|
||||
result.addScoreUpdate(competitor, raceColumn, officialCorrectionEntry.getScore().intValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -280,6 +276,9 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<ScoreCo
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return <code>null</code> if the empty string was selected
|
||||
*/
|
||||
private <T> String getSelectedString(Map<T, ListBox> choosersByT, T t) {
|
||||
String result = null;
|
||||
ListBox chooser = choosersByT.get(t);
|
||||
@@ -293,22 +292,22 @@ public class MatchAndApplyScoreCorrectionsDialog extends DataEntryDialog<ScoreCo
|
||||
return result;
|
||||
}
|
||||
|
||||
private static class Validator implements DataEntryDialog.Validator<ScoreCorrectionsApplicationInstructions> {
|
||||
private static class Validator implements DataEntryDialog.Validator<BulkScoreCorrectionDTO> {
|
||||
@Override
|
||||
public String getErrorMessage(ScoreCorrectionsApplicationInstructions valueToValidate) {
|
||||
public String getErrorMessage(BulkScoreCorrectionDTO valueToValidate) {
|
||||
// so far, nothing can go wrong :-)
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static class Callback implements AsyncCallback<ScoreCorrectionsApplicationInstructions> {
|
||||
private static class Callback implements AsyncCallback<BulkScoreCorrectionDTO> {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ScoreCorrectionsApplicationInstructions result) {
|
||||
public void onSuccess(BulkScoreCorrectionDTO result) {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
}
|
||||
|
||||
-5
@@ -1,5 +0,0 @@
|
||||
package com.sap.sailing.gwt.ui.leaderboardedit;
|
||||
|
||||
public class ScoreCorrectionsApplicationInstructions {
|
||||
|
||||
}
|
||||
+18
@@ -120,6 +120,7 @@ import com.sap.sailing.domain.tractracadapter.TracTracConfiguration;
|
||||
import com.sap.sailing.geocoding.ReverseGeocoder;
|
||||
import com.sap.sailing.gwt.ui.client.SailingService;
|
||||
import com.sap.sailing.gwt.ui.shared.BoatClassDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.BulkScoreCorrectionDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CompetitorRaceDataDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.CourseDTO;
|
||||
@@ -1529,6 +1530,23 @@ public class SailingServiceImpl extends RemoteServiceServlet implements SailingS
|
||||
new MillisecondsTimePoint(date)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLeaderboardScoreCorrectionsAndMaxPointsReasons(BulkScoreCorrectionDTO updates) throws NoWindException {
|
||||
Date dateForResults = new Date(); // we don't care about the result date/time here; use current date as default
|
||||
for (Map.Entry<String, Map<String, Integer>> e : updates.getScoreUpdatesForRaceColumnByCompetitorIdAsString().entrySet()) {
|
||||
for (Map.Entry<String, Integer> raceColumnNameAndCorrectedScore : e.getValue().entrySet()) {
|
||||
updateLeaderboardScoreCorrection(updates.getLeaderboardName(), e.getKey(),
|
||||
raceColumnNameAndCorrectedScore.getKey(), raceColumnNameAndCorrectedScore.getValue(), dateForResults);
|
||||
}
|
||||
}
|
||||
for (Map.Entry<String, Map<String, MaxPointsReason>> e : updates.getMaxPointsUpdatesForRaceColumnByCompetitorIdAsString().entrySet()) {
|
||||
for (Map.Entry<String, MaxPointsReason> raceColumnNameAndNewMaxPointsReason : e.getValue().entrySet()) {
|
||||
updateLeaderboardMaxPointsReason(updates.getLeaderboardName(), e.getKey(),
|
||||
raceColumnNameAndNewMaxPointsReason.getKey(), raceColumnNameAndNewMaxPointsReason.getValue(), dateForResults);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateCompetitorDisplayNameInLeaderboard(String leaderboardName, String competitorIdAsString, String displayName) {
|
||||
getService().apply(new UpdateCompetitorDisplayNameInLeaderboard(leaderboardName, competitorIdAsString, displayName));
|
||||
|
||||
Executable
+58
@@ -0,0 +1,58 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
import com.sap.sailing.domain.common.MaxPointsReason;
|
||||
|
||||
/**
|
||||
* Captures a collection of score corrections to apply to a leaderboard. The leaderboard is identified by name,
|
||||
* and so are the race columns. The competitors are identified by their {@link CompetitorDTO#id ID}.
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public class BulkScoreCorrectionDTO implements IsSerializable {
|
||||
private String leaderboardName;
|
||||
private Map<String, Map<String, MaxPointsReason>> maxPointsUpdatesForRaceColumnByCompetitorIdAsString;
|
||||
private Map<String, Map<String, Integer>> scoreUpdatesForRaceColumnByCompetitorIdAsString;
|
||||
|
||||
public BulkScoreCorrectionDTO() {}
|
||||
|
||||
public BulkScoreCorrectionDTO(String leaderboardName) {
|
||||
this.leaderboardName = leaderboardName;
|
||||
maxPointsUpdatesForRaceColumnByCompetitorIdAsString = new HashMap<String, Map<String,MaxPointsReason>>();
|
||||
scoreUpdatesForRaceColumnByCompetitorIdAsString = new HashMap<String, Map<String,Integer>>();
|
||||
}
|
||||
|
||||
public void addScoreUpdate(CompetitorDTO competitor, RaceColumnDTO raceColumn, int newScore) {
|
||||
Map<String, Integer> map = scoreUpdatesForRaceColumnByCompetitorIdAsString.get(competitor.id);
|
||||
if (map == null) {
|
||||
map = new HashMap<String, Integer>();
|
||||
scoreUpdatesForRaceColumnByCompetitorIdAsString.put(competitor.id, map);
|
||||
}
|
||||
map.put(raceColumn.name, newScore);
|
||||
}
|
||||
|
||||
public void addMaxPointsReasonUpdate(CompetitorDTO competitor, RaceColumnDTO raceColumn, MaxPointsReason newReason) {
|
||||
Map<String, MaxPointsReason> map = maxPointsUpdatesForRaceColumnByCompetitorIdAsString.get(competitor.id);
|
||||
if (map == null) {
|
||||
map = new HashMap<String, MaxPointsReason>();
|
||||
maxPointsUpdatesForRaceColumnByCompetitorIdAsString.put(competitor.id, map);
|
||||
}
|
||||
map.put(raceColumn.name, newReason);
|
||||
}
|
||||
|
||||
public Map<String, Map<String, MaxPointsReason>> getMaxPointsUpdatesForRaceColumnByCompetitorIdAsString() {
|
||||
return maxPointsUpdatesForRaceColumnByCompetitorIdAsString;
|
||||
}
|
||||
|
||||
public Map<String, Map<String, Integer>> getScoreUpdatesForRaceColumnByCompetitorIdAsString() {
|
||||
return scoreUpdatesForRaceColumnByCompetitorIdAsString;
|
||||
}
|
||||
|
||||
public String getLeaderboardName() {
|
||||
return leaderboardName;
|
||||
}
|
||||
}
|
||||
+3
@@ -15,6 +15,9 @@ public class UpdateLeaderboardScoreCorrection extends AbstractLeaderboardColumnO
|
||||
private final Integer correctedScore;
|
||||
private final TimePoint timePoint;
|
||||
|
||||
/**
|
||||
* @param timePoint the time point for which to deliver leaderboard results as the result of this operation
|
||||
*/
|
||||
public UpdateLeaderboardScoreCorrection(String leaderboardName, String columnName, String competitorIdAsString,
|
||||
Integer correctedScore, TimePoint timePoint) {
|
||||
super(leaderboardName, columnName);
|
||||
|
||||
Reference in new issue
Block a user