mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-24 06:28:41 +00:00
Merge branch 'bug4104' of ssh://trac@sapsailing.com/home/trac/git into
bug4104 Conflicts: java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/raceboard/TaggingPanel.java
This commit is contained in:
+6
-2
@@ -2,24 +2,28 @@ package com.sap.sailing.gwt.ui.actions;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.gwt.client.async.AsyncAction;
|
||||
|
||||
public class GetRaceTimesInfoAction implements AsyncAction<List<RaceTimesInfoDTO>> {
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final Collection<RegattaAndRaceIdentifier> raceIdentifiers;
|
||||
private final Map<RegattaAndRaceIdentifier, TimePoint> latestReceivedTagTimes;
|
||||
|
||||
public GetRaceTimesInfoAction(SailingServiceAsync sailingService, Collection<RegattaAndRaceIdentifier> raceIdentifiers) {
|
||||
public GetRaceTimesInfoAction(SailingServiceAsync sailingService, Collection<RegattaAndRaceIdentifier> raceIdentifiers, Map<RegattaAndRaceIdentifier, TimePoint> latestReceivedTagTimes) {
|
||||
this.sailingService = sailingService;
|
||||
this.raceIdentifiers = raceIdentifiers;
|
||||
this.latestReceivedTagTimes = latestReceivedTagTimes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(AsyncCallback<List<RaceTimesInfoDTO>> callback) {
|
||||
sailingService.getRaceTimesInfos(raceIdentifiers, callback);
|
||||
sailingService.getRaceTimesInfos(raceIdentifiers, latestReceivedTagTimes, callback);
|
||||
}
|
||||
}
|
||||
+13
-2
@@ -19,6 +19,7 @@ import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
|
||||
import com.sap.sailing.gwt.ui.actions.GetRaceTimesInfoAction;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.gwt.client.ErrorReporter;
|
||||
import com.sap.sse.gwt.client.async.AsyncActionsExecutor;
|
||||
|
||||
@@ -35,6 +36,8 @@ public class RaceTimesInfoProvider {
|
||||
private final Set<RaceTimesInfoProviderListener> listeners;
|
||||
private boolean terminated = false;
|
||||
|
||||
private Map<RegattaAndRaceIdentifier, TimePoint> latestReceivedTagTimes;
|
||||
|
||||
/**
|
||||
* The <code>raceIdentifiers</code> has to be non-<code>null</code>, but can be empty.
|
||||
*/
|
||||
@@ -47,6 +50,7 @@ public class RaceTimesInfoProvider {
|
||||
this.requestIntervalInMillis = requestIntervalInMillis;
|
||||
raceTimesInfos = new HashMap<RegattaAndRaceIdentifier, RaceTimesInfoDTO>();
|
||||
listeners = new HashSet<RaceTimesInfoProviderListener>();
|
||||
latestReceivedTagTimes = new HashMap<RegattaAndRaceIdentifier, TimePoint>();
|
||||
RepeatingCommand command = new RepeatingCommand() {
|
||||
@Override
|
||||
public boolean execute() {
|
||||
@@ -82,7 +86,7 @@ public class RaceTimesInfoProvider {
|
||||
raceIdentifiers.add(raceIdentifier);
|
||||
if (forceTimesInfoRequest) {
|
||||
final long clientTimeWhenRequestWasSent = System.currentTimeMillis();
|
||||
sailingService.getRaceTimesInfo(raceIdentifier, new AsyncCallback<RaceTimesInfoDTO>() {
|
||||
sailingService.getRaceTimesInfo(raceIdentifier, latestReceivedTagTimes.get(raceIdentifier), new AsyncCallback<RaceTimesInfoDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to obtain the time infos for race "
|
||||
@@ -104,7 +108,7 @@ public class RaceTimesInfoProvider {
|
||||
private void readTimesInfos() {
|
||||
if (!raceIdentifiers.isEmpty()) {
|
||||
final long clientTimeWhenRequestWasSent = System.currentTimeMillis();
|
||||
GetRaceTimesInfoAction getRaceTimesInfoAction = new GetRaceTimesInfoAction(sailingService, raceIdentifiers);
|
||||
GetRaceTimesInfoAction getRaceTimesInfoAction = new GetRaceTimesInfoAction(sailingService, raceIdentifiers, latestReceivedTagTimes);
|
||||
asyncActionsExecutor.execute(getRaceTimesInfoAction, new AsyncCallback<List<RaceTimesInfoDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
@@ -226,4 +230,11 @@ public class RaceTimesInfoProvider {
|
||||
raceTimesInfos.clear();
|
||||
}
|
||||
|
||||
public TimePoint getLatestReceivedTag(RegattaAndRaceIdentifier raceIdentifier) {
|
||||
return latestReceivedTagTimes.get(raceIdentifier);
|
||||
}
|
||||
|
||||
public void setLatestReceivedTagTime(RegattaAndRaceIdentifier raceIdentifier, TimePoint latestReceivedTagTime) {
|
||||
latestReceivedTagTimes.put(raceIdentifier, latestReceivedTagTime);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-7
@@ -101,7 +101,6 @@ import com.sap.sailing.gwt.ui.shared.SwissTimingConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SwissTimingEventRecordDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SwissTimingRaceRecordDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SwissTimingReplayRaceDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TracTracConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TracTracRaceRecordDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TrackFileImportDeviceIdentifierDTO;
|
||||
@@ -190,9 +189,9 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
|
||||
Map<String, Date> fromPerCompetitorIdAsString, Map<String, Date> toPerCompetitorIdAsString,
|
||||
boolean extrapolate) throws NoWindException;
|
||||
|
||||
RaceTimesInfoDTO getRaceTimesInfo(RegattaAndRaceIdentifier raceIdentifier);
|
||||
RaceTimesInfoDTO getRaceTimesInfo(RegattaAndRaceIdentifier raceIdentifier, TimePoint latestReceivedTagTime);
|
||||
|
||||
List<RaceTimesInfoDTO> getRaceTimesInfos(Collection<RegattaAndRaceIdentifier> raceIdentifiers);
|
||||
List<RaceTimesInfoDTO> getRaceTimesInfos(Collection<RegattaAndRaceIdentifier> raceIdentifiers, Map<RegattaAndRaceIdentifier, TimePoint> latestReceivedTagTimes);
|
||||
|
||||
CoursePositionsDTO getCoursePositions(RegattaAndRaceIdentifier raceIdentifier, Date date);
|
||||
|
||||
@@ -538,6 +537,9 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
|
||||
*/
|
||||
void addCourseDefinitionToRaceLog(String leaderboardName, String raceColumnName, String fleetName, List<Util.Pair<ControlPointDTO, PassingInstruction>> course) throws NotFoundException;
|
||||
|
||||
void addTagToRaceLog(String leaderboardName, String raceColumnName, String fleetName, String tag, String comment,
|
||||
String imageURL, TimePoint raceTimepoint);
|
||||
|
||||
RaceCourseDTO getLastCourseDefinitionInRaceLog(String leaderboardName, String raceColumnName, String fleetName) throws NotFoundException;
|
||||
|
||||
/**
|
||||
@@ -784,8 +786,4 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
|
||||
* Checks if the given race is currently in state tracking or loading.
|
||||
*/
|
||||
Boolean checkIfRaceIsTracking(RegattaAndRaceIdentifier race);
|
||||
|
||||
void addTagToRaceLog(String leaderboardName, String raceColumnName, String fleetName, String tag, String comment, String imageURL, TimePoint raceTimepoint);
|
||||
|
||||
List<TagDTO> getTags(String leaderboardName, String raceColumnName, String fleetName, TimePoint from);
|
||||
}
|
||||
|
||||
+5
-7
@@ -91,7 +91,6 @@ import com.sap.sailing.gwt.ui.shared.SwissTimingConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SwissTimingEventRecordDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SwissTimingRaceRecordDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SwissTimingReplayRaceDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TracTracConfigurationDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TracTracRaceRecordDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TrackFileImportDeviceIdentifierDTO;
|
||||
@@ -236,9 +235,9 @@ public interface SailingServiceAsync extends ServerInfoRetriever, FileStorageMan
|
||||
|
||||
void removeWind(RegattaAndRaceIdentifier raceIdentifier, WindDTO windDTO, AsyncCallback<Void> callback);
|
||||
|
||||
void getRaceTimesInfo(RegattaAndRaceIdentifier raceIdentifier, AsyncCallback<RaceTimesInfoDTO> callback);
|
||||
void getRaceTimesInfo(RegattaAndRaceIdentifier raceIdentifier, TimePoint latestReceivedTagTime, AsyncCallback<RaceTimesInfoDTO> callback);
|
||||
|
||||
void getRaceTimesInfos(Collection<RegattaAndRaceIdentifier> raceIdentifiers,
|
||||
void getRaceTimesInfos(Collection<RegattaAndRaceIdentifier> raceIdentifiers, Map<RegattaAndRaceIdentifier, TimePoint> latestReceivedTagTimes,
|
||||
AsyncCallback<List<RaceTimesInfoDTO>> callback);
|
||||
|
||||
void getCoursePositions(RegattaAndRaceIdentifier raceIdentifier, Date date,
|
||||
@@ -726,6 +725,9 @@ public interface SailingServiceAsync extends ServerInfoRetriever, FileStorageMan
|
||||
void addCourseDefinitionToRaceLog(String leaderboardName, String raceColumnName, String fleetName,
|
||||
List<Util.Pair<ControlPointDTO, PassingInstruction>> course, AsyncCallback<Void> callback);
|
||||
|
||||
void addTagToRaceLog(String leaderboardName, String raceColumnName, String fleetName, String tag, String comment,
|
||||
String imageURL, TimePoint raceTimepoint, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void getLastCourseDefinitionInRaceLog(String leaderboardName, String raceColumnName, String fleetName,
|
||||
AsyncCallback<RaceCourseDTO> callback);
|
||||
|
||||
@@ -990,8 +992,4 @@ public interface SailingServiceAsync extends ServerInfoRetriever, FileStorageMan
|
||||
* @see SailingService#checkIfRaceIsTracking(RegattaAndRaceIdentifier)
|
||||
*/
|
||||
void checkIfRaceIsTracking(RegattaAndRaceIdentifier raceIdentifier, AsyncCallback<Boolean> asyncCallback);
|
||||
|
||||
void addTagToRaceLog(String leaderboardName, String raceColumnName, String fleetName, String tag, String comment, String imageURL, TimePoint raceTimepoint, AsyncCallback<Void> asyncCallback);
|
||||
|
||||
void getTags(String leaderboardName, String raceColumnName, String fleetName, TimePoint from, AsyncCallback<List<TagDTO>> callback);
|
||||
}
|
||||
|
||||
+1
-1
@@ -302,7 +302,7 @@ public class RaceBoardPanel
|
||||
addChildComponent(raceMap);
|
||||
|
||||
// add panel for tagging functionality, hidden by default
|
||||
taggingPanel = new TaggingPanel(parent, componentContext, stringMessages, sailingService, userService, timer);
|
||||
taggingPanel = new TaggingPanel(parent, componentContext, stringMessages, sailingService, userService, timer, raceTimesInfoProvider);
|
||||
addChildComponent(taggingPanel);
|
||||
taggingPanel.setVisible(true);
|
||||
taggingPanel.setVisible(false);
|
||||
|
||||
+57
-56
@@ -3,6 +3,7 @@ package com.sap.sailing.gwt.ui.raceboard;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.gwt.cell.client.AbstractCell;
|
||||
import com.google.gwt.cell.client.ButtonCell;
|
||||
@@ -34,27 +35,30 @@ import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
|
||||
import com.sap.sailing.gwt.ui.client.RaceTimesInfoProvider;
|
||||
import com.sap.sailing.gwt.ui.client.RaceTimesInfoProviderListener;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.TagListProvider;
|
||||
import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil;
|
||||
import com.sap.sailing.gwt.ui.raceboard.TaggingPanel.TagPanelResources.TagPanelStyle;
|
||||
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.TagDTO;
|
||||
import com.sap.sse.common.TimePoint;
|
||||
import com.sap.sse.common.impl.MillisecondsTimePoint;
|
||||
import com.sap.sse.gwt.client.Notification;
|
||||
import com.sap.sse.gwt.client.Notification.NotificationType;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
import com.sap.sse.gwt.client.player.TimeListener;
|
||||
import com.sap.sse.gwt.client.player.Timer;
|
||||
import com.sap.sse.gwt.client.shared.components.Component;
|
||||
import com.sap.sse.gwt.client.shared.components.ComponentWithoutSettings;
|
||||
import com.sap.sse.gwt.client.shared.settings.ComponentContext;
|
||||
import com.sap.sse.security.ui.client.UserService;
|
||||
|
||||
public class TaggingPanel extends ComponentWithoutSettings implements TimeListener {
|
||||
public class TaggingPanel extends ComponentWithoutSettings implements RaceTimesInfoProviderListener {
|
||||
|
||||
public interface TagPanelResources extends ClientBundle {
|
||||
public static final TagPanelResources INSTANCE = GWT.create(TagPanelResources.class);
|
||||
@@ -150,10 +154,10 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
htmlBuilder.append(cell);
|
||||
}
|
||||
}
|
||||
|
||||
private class TagButton extends Button{
|
||||
private String tag, imageURL, comment;
|
||||
|
||||
|
||||
private class TagButton extends Button {
|
||||
private String tag, imageURL, comment;
|
||||
|
||||
public TagButton(String buttonName, String tag, String imageURL, String comment) {
|
||||
super(buttonName);
|
||||
this.tag = tag;
|
||||
@@ -179,27 +183,27 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
return comment;
|
||||
}
|
||||
}
|
||||
|
||||
private class TagCreationPanel extends VerticalPanel{
|
||||
|
||||
private class TagCreationPanel extends VerticalPanel {
|
||||
protected Button createTagFromTextBoxes, editCustomTagButtons;
|
||||
protected Panel customButtonsPanel = new FlowPanel();
|
||||
private final TagCreationInputPanel inputPanel;
|
||||
|
||||
private final TagCreationInputPanel inputPanel;
|
||||
public TagCreationPanel(StringMessages stringMessages) {
|
||||
inputPanel = new TagCreationInputPanel(stringMessages);
|
||||
add(inputPanel);
|
||||
|
||||
|
||||
createTagFromTextBoxes = new Button(stringMessages.tagAddButton());
|
||||
createTagFromTextBoxes.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
public void onClick(ClickEvent event) {
|
||||
if (isAuthorized()) {
|
||||
addNewTag(inputPanel.getTagValue(), inputPanel.getCommentValue(), inputPanel.getImageURLValue());
|
||||
addNewTag(inputPanel.getTagValue(), inputPanel.getCommentValue(),
|
||||
inputPanel.getImageURLValue());
|
||||
}
|
||||
}
|
||||
});
|
||||
add(createTagFromTextBoxes);
|
||||
|
||||
|
||||
editCustomTagButtons = new Button(stringMessages.tagEditCustomTagButtons());
|
||||
editCustomTagButtons.addClickHandler(new ClickHandler() {
|
||||
@Override
|
||||
@@ -211,10 +215,10 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
}
|
||||
});
|
||||
add(editCustomTagButtons);
|
||||
|
||||
|
||||
add(customButtonsPanel);
|
||||
}
|
||||
|
||||
|
||||
private void updateButtons() {
|
||||
customButtonsPanel.clear();
|
||||
customTagButtons.forEach(button -> {
|
||||
@@ -229,9 +233,8 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
public EditCustomTagsDialog(Panel customButtonsPanel) {
|
||||
super(stringMessages.tagEditCustomTagsButtonDialogHeader(), "", stringMessages.ok(), stringMessages.cancel(), null, null);
|
||||
this.customButtonsPanel = customButtonsPanel;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected Widget getAdditionalWidget() {
|
||||
Panel mainPanel = new HorizontalPanel();
|
||||
@@ -291,7 +294,7 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
}
|
||||
});
|
||||
rightPanel.add(addCustomTagButton);
|
||||
|
||||
|
||||
return mainPanel;
|
||||
}
|
||||
|
||||
@@ -301,7 +304,6 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private final HeaderPanel panel;
|
||||
private final TagCreationPanel tagCreationPanel;
|
||||
@@ -317,14 +319,15 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final UserService userService;
|
||||
private final Timer timer;
|
||||
private final RaceTimesInfoProvider raceTimesInfoProvider;
|
||||
|
||||
private String leaderboardName = null;
|
||||
private RaceColumnDTO raceColumn = null;
|
||||
private FleetDTO fleet = null;
|
||||
private TimePoint lastReceivedTag = null;
|
||||
|
||||
public TaggingPanel(Component<?> parent, ComponentContext<?> context, StringMessages stringMessages,
|
||||
SailingServiceAsync sailingService, UserService userService, Timer timer) {
|
||||
SailingServiceAsync sailingService, UserService userService, Timer timer,
|
||||
RaceTimesInfoProvider raceTimesInfoProvider) {
|
||||
super(parent, context);
|
||||
|
||||
TagPanelResources.INSTANCE.style().ensureInjected();
|
||||
@@ -339,21 +342,23 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
tagSelectionModel = new SingleSelectionModel<TagDTO>();
|
||||
|
||||
contentPanel = new ScrollPanel();
|
||||
tagCreationPanel = new TagCreationPanel(stringMessages);
|
||||
tagCreationPanel = new TagCreationPanel(stringMessages);
|
||||
|
||||
this.stringMessages = stringMessages;
|
||||
this.sailingService = sailingService;
|
||||
this.userService = userService;
|
||||
this.timer = timer;
|
||||
timer.addTimeListener(this);
|
||||
this.raceTimesInfoProvider = raceTimesInfoProvider;
|
||||
raceTimesInfoProvider.addRaceTimesInfoProviderListener(this);
|
||||
|
||||
initializePanel();
|
||||
}
|
||||
|
||||
public TaggingPanel(Component<?> parent, ComponentContext<?> context, StringMessages stringMessages,
|
||||
SailingServiceAsync sailingService, UserService userService, Timer timer, String leaderboardName,
|
||||
RaceColumnDTO raceColumn, FleetDTO fleet) {
|
||||
this(parent, context, stringMessages, sailingService, userService, timer);
|
||||
SailingServiceAsync sailingService, UserService userService, Timer timer,
|
||||
RaceTimesInfoProvider raceTimesInfoProvider, String leaderboardName, RaceColumnDTO raceColumn,
|
||||
FleetDTO fleet) {
|
||||
this(parent, context, stringMessages, sailingService, userService, timer, raceTimesInfoProvider);
|
||||
updateRace(leaderboardName, raceColumn, fleet);
|
||||
}
|
||||
|
||||
@@ -439,37 +444,33 @@ public class TaggingPanel extends ComponentWithoutSettings implements TimeListen
|
||||
}
|
||||
|
||||
@Override
|
||||
public void timeChanged(Date newTime, Date oldTime) {
|
||||
if (leaderboardName != null && raceColumn != null && fleet != null && panel.isAttached() && panel.isVisible()
|
||||
&& oldTime != null) {
|
||||
// load tags since last received tag => decrease required bandwidth as only difference in tags will be sent
|
||||
// over network
|
||||
sailingService.getTags(leaderboardName, raceColumn.getName(), fleet.getName(), lastReceivedTag,
|
||||
new AsyncCallback<List<TagDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
Notification.notify(stringMessages.tagNotLoaded(), NotificationType.ERROR);
|
||||
public void raceTimesInfosReceived(Map<RegattaAndRaceIdentifier, RaceTimesInfoDTO> raceTimesInfo,
|
||||
long clientTimeWhenRequestWasSent, Date serverTimeDuringRequest, long clientTimeWhenResponseWasReceived) {
|
||||
raceTimesInfo.forEach((raceIdentifier, raceInfo) -> {
|
||||
boolean addedTag = false;
|
||||
boolean updatedLatestTag = false;
|
||||
if (raceIdentifier.equals(raceInfo.getRaceIdentifier())) {
|
||||
List<TagDTO> currentTags = tagListProvider.getAllTags();
|
||||
TimePoint latestReceivedTagTime = raceTimesInfoProvider.getLatestReceivedTag(raceIdentifier);
|
||||
for (TagDTO tag : raceInfo.getTags()) {
|
||||
if (!currentTags.contains(tag)) {
|
||||
currentTags.add(tag);
|
||||
addedTag = true;
|
||||
if (latestReceivedTagTime == null || (latestReceivedTagTime != null
|
||||
&& latestReceivedTagTime.before(tag.getCreatedAt()))) {
|
||||
latestReceivedTagTime = tag.getCreatedAt();
|
||||
updatedLatestTag = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<TagDTO> result) {
|
||||
if (result != null) {
|
||||
List<TagDTO> tags = tagListProvider.getAllTags();
|
||||
for (TagDTO tag : result) {
|
||||
if (!tags.contains(tag)) {
|
||||
tags.add(tag);
|
||||
if (lastReceivedTag == null) {
|
||||
lastReceivedTag = tag.getCreatedAt();
|
||||
} else if (lastReceivedTag.before(tag.getCreatedAt())) {
|
||||
lastReceivedTag = tag.getCreatedAt();
|
||||
}
|
||||
updateContent();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
if (updatedLatestTag) {
|
||||
raceTimesInfoProvider.setLatestReceivedTagTime(raceIdentifier, latestReceivedTagTime);
|
||||
}
|
||||
if (addedTag) {
|
||||
updateContent();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+24
-26
@@ -2063,7 +2063,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
public RaceTimesInfoDTO getRaceTimesInfo(RegattaAndRaceIdentifier raceIdentifier) {
|
||||
public RaceTimesInfoDTO getRaceTimesInfo(RegattaAndRaceIdentifier raceIdentifier, TimePoint latestReceivedTagTime) {
|
||||
RaceTimesInfoDTO raceTimesInfo = null;
|
||||
TrackedRace trackedRace = getExistingTrackedRace(raceIdentifier);
|
||||
|
||||
@@ -2073,6 +2073,8 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
raceTimesInfo.setLegInfos(legInfos);
|
||||
List<MarkPassingTimesDTO> markPassingTimesDTOs = new ArrayList<MarkPassingTimesDTO>();
|
||||
raceTimesInfo.setMarkPassingTimes(markPassingTimesDTOs);
|
||||
List<TagDTO> tags = new ArrayList<TagDTO>();
|
||||
raceTimesInfo.setTags(tags);
|
||||
|
||||
raceTimesInfo.startOfRace = trackedRace.getStartOfRace() == null ? null : trackedRace.getStartOfRace().asDate();
|
||||
raceTimesInfo.startOfTracking = trackedRace.getStartOfTracking() == null ? null : trackedRace.getStartOfTracking().asDate();
|
||||
@@ -2125,6 +2127,16 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
} finally {
|
||||
trackedRace.getRace().getCourse().unlockAfterRead();
|
||||
}
|
||||
|
||||
Iterable<RaceLog> raceLogs = trackedRace.getAttachedRaceLogs();
|
||||
for (RaceLog raceLog : raceLogs) {
|
||||
TagFinder tagFinder = new TagFinder(raceLog, latestReceivedTagTime);
|
||||
List<RaceLogTagEvent> foundTagEvents = tagFinder.analyze();
|
||||
for (RaceLogTagEvent tagEvent : foundTagEvents) {
|
||||
tags.add(new TagDTO(tagEvent.getTag(), tagEvent.getComment(), tagEvent.getImageURL(),
|
||||
tagEvent.getUsername(), tagEvent.getLogicalTimePoint(), tagEvent.getCreatedAt()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (raceTimesInfo != null) {
|
||||
raceTimesInfo.currentServerTime = new Date();
|
||||
@@ -2133,10 +2145,10 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<RaceTimesInfoDTO> getRaceTimesInfos(Collection<RegattaAndRaceIdentifier> raceIdentifiers) {
|
||||
public List<RaceTimesInfoDTO> getRaceTimesInfos(Collection<RegattaAndRaceIdentifier> raceIdentifiers, Map<RegattaAndRaceIdentifier, TimePoint> latestReceivedTagTimes) {
|
||||
List<RaceTimesInfoDTO> raceTimesInfos = new ArrayList<RaceTimesInfoDTO>();
|
||||
for (RegattaAndRaceIdentifier raceIdentifier : raceIdentifiers) {
|
||||
RaceTimesInfoDTO raceTimesInfo = getRaceTimesInfo(raceIdentifier);
|
||||
RaceTimesInfoDTO raceTimesInfo = getRaceTimesInfo(raceIdentifier, latestReceivedTagTimes.get(raceIdentifier));
|
||||
if (raceTimesInfo != null) {
|
||||
raceTimesInfos.add(raceTimesInfo);
|
||||
}
|
||||
@@ -6033,7 +6045,15 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
getService().getServerAuthor(), raceLog.getCurrentPassId(), course, CourseDesignerMode.ADMIN_CONSOLE);
|
||||
raceLog.add(event);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void addTagToRaceLog(String leaderboardName, String raceColumnName, String fleetName, String tag,
|
||||
String comment, String imageURL, TimePoint raceTimepoint) {
|
||||
RaceLog raceLog = getService().getRaceLog(leaderboardName, raceColumnName, fleetName);
|
||||
raceLog.add(new RaceLogTagEventImpl(tag, comment, imageURL, raceTimepoint, getService().getServerAuthor(),
|
||||
raceLog.getCurrentPassId()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param trackedRace
|
||||
* if <code>null</code>, no position data will be attached to the {@link MarkDTO}s
|
||||
@@ -7895,26 +7915,4 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addTagToRaceLog(String leaderboardName, String raceColumnName, String fleetName, String tag, String comment, String imageURL, TimePoint raceTimepoint) {
|
||||
RaceLog raceLog = getService().getRaceLog(leaderboardName, raceColumnName, fleetName);
|
||||
raceLog.add(new RaceLogTagEventImpl(tag, comment, imageURL, raceTimepoint, getService().getServerAuthor(), raceLog.getCurrentPassId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
/**
|
||||
* @param from may be null, results in loading every tag since the race start
|
||||
*/
|
||||
public List<TagDTO> getTags(String leaderboardName, String raceColumnName, String fleetName, TimePoint from) {
|
||||
RaceLog raceLog = getService().getRaceLog(leaderboardName, raceColumnName, fleetName);
|
||||
TagFinder tagFinder = new TagFinder(raceLog, from);
|
||||
List<RaceLogTagEvent> foundTagEvents = tagFinder.analyze();
|
||||
|
||||
List<TagDTO> result = new ArrayList<>();
|
||||
for(RaceLogTagEvent tagEvent : foundTagEvents) {
|
||||
result.add(new TagDTO(tagEvent.getTag(), tagEvent.getComment(), tagEvent.getImageURL(), tagEvent.getUsername(), tagEvent.getLogicalTimePoint(), tagEvent.getCreatedAt()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
+19
-12
@@ -14,7 +14,9 @@ public class RaceTimesInfoDTO implements IsSerializable {
|
||||
public List<LegInfoDTO> legInfos;
|
||||
|
||||
public List<MarkPassingTimesDTO> markPassingTimes;
|
||||
|
||||
|
||||
public List<TagDTO> tags;
|
||||
|
||||
public Date startOfRace;
|
||||
public Date startOfTracking;
|
||||
public Date endOfTracking;
|
||||
@@ -116,16 +118,21 @@ public class RaceTimesInfoDTO implements IsSerializable {
|
||||
public void setMarkPassingTimes(List<MarkPassingTimesDTO> markPassingTimes) {
|
||||
this.markPassingTimes = markPassingTimes;
|
||||
}
|
||||
|
||||
|
||||
public List<TagDTO> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(List<TagDTO> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RaceTimesInfoDTO [raceIdentifier=" + raceIdentifier
|
||||
+ ", legInfos=" + legInfos + ", markPassingTimes="
|
||||
+ markPassingTimes + ", startOfRace=" + startOfRace
|
||||
+ ", startOfTracking=" + startOfTracking + ", endOfTracking="
|
||||
+ endOfTracking + ", endOfRace=" + endOfRace + ", finishedTime=" + raceFinishedTime
|
||||
+ ", newestTrackingEvent=" + newestTrackingEvent
|
||||
+ ", currentServerTime=" + currentServerTime
|
||||
+ ", delayToLiveInMs=" + delayToLiveInMs + "]";
|
||||
}
|
||||
public String toString() {
|
||||
return "RaceTimesInfoDTO [raceIdentifier=" + raceIdentifier + ", legInfos=" + legInfos + ", markPassingTimes="
|
||||
+ markPassingTimes + ", tags=" + tags + ", startOfRace=" + startOfRace + ", startOfTracking="
|
||||
+ startOfTracking + ", endOfTracking=" + endOfTracking + ", endOfRace=" + endOfRace + ", finishedTime="
|
||||
+ raceFinishedTime + ", newestTrackingEvent=" + newestTrackingEvent + ", currentServerTime="
|
||||
+ currentServerTime + ", delayToLiveInMs=" + delayToLiveInMs + "]";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user