Merge branch 'master' into ubilabs--rcapp--develop

This commit is contained in:
Peter Siegmund committed 2015-03-27 11:23:20 +01:00
commit 7f7c8bc390
26 files changed
+437 -242

No files matched your search

@@ -277,7 +277,8 @@ public class IgtimiConnectionImpl implements IgtimiConnection {
TimePoint endOfWindow = new MillisecondsTimePoint(0); TimePoint endOfWindow = new MillisecondsTimePoint(0);
for (DynamicTrackedRace trackedRace : trackedRaces) { for (DynamicTrackedRace trackedRace : trackedRaces) {
startOfWindow = Collections.min(Arrays.asList(startOfWindow, IgtimiWindTracker.getReceivingStartTime(trackedRace))); startOfWindow = Collections.min(Arrays.asList(startOfWindow, IgtimiWindTracker.getReceivingStartTime(trackedRace)));
endOfWindow = Collections.max(Arrays.asList(endOfWindow, IgtimiWindTracker.getReceivingEndTime(trackedRace))); final TimePoint receivingEndTime = IgtimiWindTracker.getReceivingEndTime(trackedRace);
endOfWindow = Collections.max(Arrays.asList(endOfWindow, receivingEndTime==null?MillisecondsTimePoint.now():receivingEndTime));
} }
Iterable<DataAccessWindow> daws = getDataAccessWindows(Permission.read, startOfWindow, endOfWindow, /* find all deviceSerialNumbers for window */ null); Iterable<DataAccessWindow> daws = getDataAccessWindows(Permission.read, startOfWindow, endOfWindow, /* find all deviceSerialNumbers for window */ null);
logger.info("Found "+Util.size(daws)+" data access windows. Analyzing which ones contain wind data..."); logger.info("Found "+Util.size(daws)+" data access windows. Analyzing which ones contain wind data...");
@@ -80,14 +80,15 @@ public class MongoGPSFixStoreImpl implements MongoGPSFixStore {
private <FixT extends GPSFix> void loadTrack(DynamicGPSFixTrack<?, FixT> track, DeviceIdentifier device, private <FixT extends GPSFix> void loadTrack(DynamicGPSFixTrack<?, FixT> track, DeviceIdentifier device,
TimePoint from, TimePoint to, boolean inclusive) throws NoCorrespondingServiceRegisteredException, TimePoint from, TimePoint to, boolean inclusive) throws NoCorrespondingServiceRegisteredException,
TransformationException { TransformationException {
long fromMillis = from.asMillis() - (inclusive ? 1 : 0);
long toMillis = to.asMillis() + (inclusive ? 1 : 0);
Object dbDeviceId = MongoObjectFactoryImpl.storeDeviceId(deviceServiceFinder, device); Object dbDeviceId = MongoObjectFactoryImpl.storeDeviceId(deviceServiceFinder, device);
final QueryBuilder queryBuilder = QueryBuilder.start(FieldNames.DEVICE_ID.name()).is(dbDeviceId)
DBObject query = QueryBuilder.start(FieldNames.DEVICE_ID.name()).is(dbDeviceId) .and(FieldNames.TIME_AS_MILLIS.name());
.and(FieldNames.TIME_AS_MILLIS.name()).greaterThan(fromMillis) if (inclusive) {
.and(FieldNames.TIME_AS_MILLIS.name()).lessThan(toMillis).get(); queryBuilder.greaterThanEquals(from.asMillis()).and(FieldNames.TIME_AS_MILLIS.name()).lessThanEquals(to.asMillis());
} else {
queryBuilder.greaterThan(from.asMillis()).and(FieldNames.TIME_AS_MILLIS.name()).lessThan(to.asMillis());
}
DBObject query = queryBuilder.get();
DBCursor result = fixesCollection.find(query); DBCursor result = fixesCollection.find(query);
for (DBObject fixObject : result) { for (DBObject fixObject : result) {
@@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -100,8 +101,8 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
private final DynamicTrackedRegatta regatta; private final DynamicTrackedRegatta regatta;
private final Map<AbstractLog<?, ?>, Object> visitors = new HashMap<AbstractLog<?, ?>, Object>(); private final Map<AbstractLog<?, ?>, Object> visitors = new HashMap<AbstractLog<?, ?>, Object>();
private Map<Competitor, List<DeviceMapping<Competitor>>> competitorMappings = new HashMap<>(); private ConcurrentHashMap<Competitor, List<DeviceMapping<Competitor>>> competitorMappings = new ConcurrentHashMap<>();
private Map<Mark, List<DeviceMapping<Mark>>> markMappings = new HashMap<>(); private ConcurrentHashMap<Mark, List<DeviceMapping<Mark>>> markMappings = new ConcurrentHashMap<>();
private Map<DeviceIdentifier, List<DeviceMapping<Mark>>> markMappingsByDevices = new HashMap<>(); private Map<DeviceIdentifier, List<DeviceMapping<Mark>>> markMappingsByDevices = new HashMap<>();
private Map<DeviceIdentifier, List<DeviceMapping<Competitor>>> competitorMappingsByDevices = new HashMap<>(); private Map<DeviceIdentifier, List<DeviceMapping<Competitor>>> competitorMappingsByDevices = new HashMap<>();
@@ -244,7 +245,6 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
TimePoint earliestMappingStart = new MillisecondsTimePoint(Long.MAX_VALUE); TimePoint earliestMappingStart = new MillisecondsTimePoint(Long.MAX_VALUE);
TimePoint latestMappingEnd = new MillisecondsTimePoint(Long.MIN_VALUE); TimePoint latestMappingEnd = new MillisecondsTimePoint(Long.MIN_VALUE);
synchronized (competitorMappings) {
for (List<? extends DeviceMapping<?>> list : competitorMappings.values()) { for (List<? extends DeviceMapping<?>> list : competitorMappings.values()) {
for (DeviceMapping<?> mapping : list) { for (DeviceMapping<?> mapping : list) {
if (mapping.getTimeRange().from().before(earliestMappingStart)) { if (mapping.getTimeRange().from().before(earliestMappingStart)) {
@@ -255,9 +255,7 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
} }
} }
} }
}
synchronized (markMappings) {
for (List<? extends DeviceMapping<?>> list : markMappings.values()) { for (List<? extends DeviceMapping<?>> list : markMappings.values()) {
for (DeviceMapping<?> mapping : list) { for (DeviceMapping<?> mapping : list) {
if (mapping.getTimeRange().from().before(earliestMappingStart)) { if (mapping.getTimeRange().from().before(earliestMappingStart)) {
@@ -268,7 +266,6 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
} }
} }
} }
}
trackedRace.setStartOfTrackingReceived(earliestMappingStart); trackedRace.setStartOfTrackingReceived(earliestMappingStart);
trackedRace.setEndOfTrackingReceived(latestMappingEnd); trackedRace.setEndOfTrackingReceived(latestMappingEnd);
@@ -308,8 +305,6 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
private void updateMarkMappings(boolean loadIfNotCovered) { private void updateMarkMappings(boolean loadIfNotCovered) {
// TODO remove fixes, if mappings have been removed // TODO remove fixes, if mappings have been removed
synchronized (markMappings) {
// check if there are new time ranges not covered so far // check if there are new time ranges not covered so far
Map<Mark, List<DeviceMapping<Mark>>> newMappings = getNewMarkMappings(); Map<Mark, List<DeviceMapping<Mark>>> newMappings = getNewMarkMappings();
@@ -337,7 +332,6 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
markMappingsByDevices.clear(); markMappingsByDevices.clear();
markMappingsByDevices.putAll(transformToMappingsByDevice(markMappings)); markMappingsByDevices.putAll(transformToMappingsByDevice(markMappings));
}
updateStartAndEndOfTracking(); updateStartAndEndOfTracking();
} }
@@ -359,7 +353,6 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
private void updateCompetitorMappings(boolean loadIfNotCovered) { private void updateCompetitorMappings(boolean loadIfNotCovered) {
// TODO remove fixes, if mappings have been removed // TODO remove fixes, if mappings have been removed
synchronized (competitorMappings) {
// check if there are new time ranges not covered so far // check if there are new time ranges not covered so far
Map<Competitor, List<DeviceMapping<Competitor>>> newMappings = getNewCompetitorMappings(); Map<Competitor, List<DeviceMapping<Competitor>>> newMappings = getNewCompetitorMappings();
@@ -385,15 +378,15 @@ public class RaceLogRaceTracker implements RaceTracker, GPSFixReceivedListener {
competitorMappingsByDevices.clear(); competitorMappingsByDevices.clear();
competitorMappingsByDevices.putAll(transformToMappingsByDevice(competitorMappings)); competitorMappingsByDevices.putAll(transformToMappingsByDevice(competitorMappings));
}
updateStartAndEndOfTracking(); updateStartAndEndOfTracking();
} }
private void onStartTrackingEvent(RaceLogStartTrackingEvent event) { private void onStartTrackingEvent(RaceLogStartTrackingEvent event) {
if (trackedRace == null) if (trackedRace == null) {
startTracking(event); startTracking(event);
} }
}
private void onCourseDesignChangedEvent(RaceLogCourseDesignChangedEvent event) { private void onCourseDesignChangedEvent(RaceLogCourseDesignChangedEvent event) {
if (trackedRace == null) if (trackedRace == null)
@@ -129,4 +129,10 @@ public class TimeRangeTest {
assertEquals(0, one.timeDifference(new MillisecondsTimePoint(7)).asMillis()); assertEquals(0, one.timeDifference(new MillisecondsTimePoint(7)).asMillis());
assertEquals(2, one.timeDifference(new MillisecondsTimePoint(12)).asMillis()); assertEquals(2, one.timeDifference(new MillisecondsTimePoint(12)).asMillis());
} }
@Test
public void testEndOfTime() {
assertTrue(TimePoint.EndOfTime.after(TimePoint.BeginningOfTime));
assertTrue(TimePoint.EndOfTime.after(MillisecondsTimePoint.now()));
}
} }
@@ -46,6 +46,7 @@ import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.client.shared.controls.SelectionCheckboxColumn; import com.sap.sailing.gwt.ui.client.shared.controls.SelectionCheckboxColumn;
import com.sap.sailing.gwt.ui.shared.RaceLogDTO; import com.sap.sailing.gwt.ui.shared.RaceLogDTO;
import com.sap.sailing.gwt.ui.shared.RegattaDTO; import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sailing.gwt.ui.shared.RegattaLogDTO;
import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO; import com.sap.sailing.gwt.ui.shared.StrippedLeaderboardDTO;
import com.sap.sse.common.Util; import com.sap.sse.common.Util;
import com.sap.sse.gwt.client.ErrorReporter; import com.sap.sse.gwt.client.ErrorReporter;
@@ -619,4 +620,33 @@ public abstract class AbstractLeaderboardConfigPanel extends FormPanel implement
}); });
dialog.show(); dialog.show();
} }
protected void showRegattaLog() {
final String selectedLeaderboardName = getSelectedLeaderboardName();
sailingService.getRegattaLog(selectedLeaderboardName,
new MarkedAsyncCallback<RegattaLogDTO>(
new AsyncCallback<RegattaLogDTO>() {
@Override
public void onFailure(Throwable caught) {
errorReporter.reportError(caught.getMessage(), true);
}
@Override
public void onSuccess(RegattaLogDTO result) {
openRegattaLogDialog(result);
}
}));
}
private void openRegattaLogDialog(RegattaLogDTO regattaLogDTO) {
RegattaLogDialog dialog = new RegattaLogDialog(regattaLogDTO, stringMessages, new DialogCallback<RegattaLogDTO>() {
@Override
public void cancel() {
}
@Override
public void ok(RegattaLogDTO result) {
}
});
dialog.show();
}
} }
@@ -0,0 +1,184 @@
package com.sap.sailing.gwt.ui.adminconsole;
import java.util.Comparator;
import java.util.Date;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionModel;
import com.google.gwt.view.client.SingleSelectionModel;
import com.sap.sailing.domain.common.impl.NaturalComparator;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil;
import com.sap.sailing.gwt.ui.shared.AbstractLogDTO;
import com.sap.sailing.gwt.ui.shared.AbstractLogEventDTO;
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
public abstract class AbstractLogDialog<R extends AbstractLogDTO<E>, E extends AbstractLogEventDTO> extends DataEntryDialog<R> {
private final R logDTO;
private final SelectionModel<E> selectionModel;
private final CellTable<E> raceLogEventsTable;
private ListDataProvider<E> raceLogEventsList;
public AbstractLogDialog(final R logDTO, final StringMessages stringMessages, String logName, DialogCallback<R> callback) {
super(logName, null, stringMessages.ok(), stringMessages.cancel(), /* validator */ null, callback);
this.logDTO = logDTO;
raceLogEventsList = new ListDataProvider<E>();
selectionModel = new SingleSelectionModel<E>();
AdminConsoleTableResources tableRes = GWT.create(AdminConsoleTableResources.class);
raceLogEventsTable = new CellTable<E>(/* pageSize */10000, tableRes);
raceLogEventsTable.ensureDebugId("TrackedRacesTable");
raceLogEventsTable.setSelectionModel(selectionModel);
raceLogEventsList.setList(logDTO.getEntries());
ListHandler<E> columnSortHandler = new ListHandler<>(raceLogEventsList.getList());
raceLogEventsTable.addColumnSortHandler(columnSortHandler);
TextColumn<E> logEventAuthorColumn = new TextColumn<E>() {
@Override
public String getValue(E logEventDTO) {
return String.valueOf(logEventDTO.getAuthorName());
}
};
logEventAuthorColumn.setSortable(true);
columnSortHandler.setComparator(logEventAuthorColumn, new Comparator<E>() {
@Override
public int compare(E r1, E r2) {
return new NaturalComparator().compare(r1.getAuthorName(), r1.getAuthorName());
}
});
TextColumn<E> logEventAuthorPriorityColumn = new TextColumn<E>() {
@Override
public String getValue(E logEventDTO) {
return String.valueOf(logEventDTO.getAuthorPriority());
}
};
logEventAuthorPriorityColumn.setSortable(true);
columnSortHandler.setComparator(logEventAuthorPriorityColumn, new Comparator<E>() {
@Override
public int compare(E r1, E r2) {
return r1.getAuthorPriority() - r2.getAuthorPriority();
}
});
TextColumn<E> logEventCreatedColumn = new TextColumn<E>() {
@Override
public String getValue(E raceLogEventDTO) {
Date createdAt = raceLogEventDTO.getCreatedAt();
if(createdAt != null) {
return DateAndTimeFormatterUtil.defaultDateFormatter.render(createdAt) + " " +
DateAndTimeFormatterUtil.defaultTimeFormatter.render(createdAt);
}
return "";
}
};
logEventCreatedColumn.setSortable(true);
columnSortHandler.setComparator(logEventCreatedColumn, new Comparator<E>() {
@Override
public int compare(E r1, E r2) {
if (r1.getCreatedAt() != null && r2.getCreatedAt() != null) {
return r1.getCreatedAt().compareTo(r2.getCreatedAt());
}
return r1.getCreatedAt() == null ? (r2.getCreatedAt() == null ? 0 : -1) : 1;
}
});
TextColumn<E> logEventLogicalTimeColumn = new TextColumn<E>() {
@Override
public String getValue(E logEventDTO) {
Date logicalTimePoint = logEventDTO.getLogicalTimePoint();
if (logicalTimePoint != null) {
return DateAndTimeFormatterUtil.defaultDateFormatter.render(logicalTimePoint) + " " +
DateAndTimeFormatterUtil.defaultTimeFormatter.render(logicalTimePoint);
}
return "";
}
};
logEventLogicalTimeColumn.setSortable(true);
columnSortHandler.setComparator(logEventLogicalTimeColumn, new Comparator<E>() {
@Override
public int compare(E r1, E r2) {
if (r1.getLogicalTimePoint() != null && r2.getLogicalTimePoint() != null) {
return r1.getLogicalTimePoint().compareTo(r2.getLogicalTimePoint());
}
return r1.getLogicalTimePoint() == null ? (r2.getLogicalTimePoint() == null ? 0 : -1) : 1;
}
});
TextColumn<E> logEventTypeColumn = new TextColumn<E>() {
@Override
public String getValue(E logEventDTO) {
return logEventDTO.getType();
}
};
logEventTypeColumn.setSortable(true);
columnSortHandler.setComparator(logEventTypeColumn, new Comparator<E>() {
@Override
public int compare(E r1, E r2) {
return new NaturalComparator().compare(r1.getType(), r2.getType());
}
});
TextColumn<E> logEventInfoColumn = new TextColumn<E>() {
@Override
public String getValue(E logEventDTO) {
return logEventDTO.getInfo();
}
};
logEventInfoColumn.setSortable(true);
columnSortHandler.setComparator(logEventInfoColumn, new Comparator<E>() {
@Override
public int compare(E o1, E o2) {
return new NaturalComparator().compare(o1.getInfo(), o2.getInfo());
}
});
addFirstColumns(raceLogEventsTable, columnSortHandler);
raceLogEventsTable.addColumn(logEventTypeColumn, stringMessages.type());
raceLogEventsTable.addColumn(logEventCreatedColumn, "Created at");
raceLogEventsTable.addColumn(logEventLogicalTimeColumn, "Logical timepoint");
raceLogEventsTable.addColumn(logEventAuthorColumn, "Author");
raceLogEventsTable.addColumn(logEventAuthorPriorityColumn, "Priority");
raceLogEventsTable.addColumn(logEventInfoColumn, "Info");
addLastColumns(raceLogEventsTable, columnSortHandler);
raceLogEventsList.addDataDisplay(raceLogEventsTable);
raceLogEventsTable.getColumnSortList().push(logEventLogicalTimeColumn);
}
protected void addFirstColumns(CellTable<E> table, ListHandler<E> columnSortHandler) {}
protected void addLastColumns(CellTable<E> table, ListHandler<E> columnSortHandler) {}
@Override
protected R getResult() {
return null;
}
@Override
protected Widget getAdditionalWidget() {
VerticalPanel vPanel = new VerticalPanel();
addFirstWidgetComponents(vPanel);
ScrollPanel scrollPanel = new ScrollPanel(raceLogEventsTable);
scrollPanel.setSize("960px", "500px");
vPanel.add(scrollPanel);
addLastWidgetComponents(vPanel);
return vPanel;
}
protected R getLogDTO() {
return logDTO;
}
protected void addFirstWidgetComponents(VerticalPanel vPanel) {}
protected void addLastWidgetComponents(VerticalPanel vPanel) {}
}
@@ -16,6 +16,7 @@ public class LeaderboardConfigImagesBarCell extends ImagesBarCell {
public static final String ACTION_CONFIGURE_URL = "ACTION_CONFIGURE_URL"; public static final String ACTION_CONFIGURE_URL = "ACTION_CONFIGURE_URL";
public static final String ACTION_EXPORT_XML = "ACTION_EXPORT_XML"; public static final String ACTION_EXPORT_XML = "ACTION_EXPORT_XML";
public static final String ACTION_OPEN_COACH_DASHBOARD = "ACTION_OPEN_COACH_DASHBOARD"; public static final String ACTION_OPEN_COACH_DASHBOARD = "ACTION_OPEN_COACH_DASHBOARD";
public static final String ACTION_SHOW_REGATTA_LOG = "ACTION_SHOW_REGATTA_LOG";
private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class); private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
private final StringMessages stringMessages; private final StringMessages stringMessages;
@@ -38,6 +39,7 @@ public class LeaderboardConfigImagesBarCell extends ImagesBarCell {
new ImageSpec(ACTION_CONFIGURE_URL, stringMessages.actionConfigureUrl(), makeImagePrototype(resources.settingsActionIcon())), new ImageSpec(ACTION_CONFIGURE_URL, stringMessages.actionConfigureUrl(), makeImagePrototype(resources.settingsActionIcon())),
new ImageSpec(ACTION_REMOVE, stringMessages.actionRemove(), makeImagePrototype(IconResources.INSTANCE.removeIcon())), new ImageSpec(ACTION_REMOVE, stringMessages.actionRemove(), makeImagePrototype(IconResources.INSTANCE.removeIcon())),
new ImageSpec(ACTION_EXPORT_XML, stringMessages.actionExportXML(), makeImagePrototype(resources.exportXMLIcon())), new ImageSpec(ACTION_EXPORT_XML, stringMessages.actionExportXML(), makeImagePrototype(resources.exportXMLIcon())),
new ImageSpec(ACTION_OPEN_COACH_DASHBOARD, stringMessages.actionOpenDashboard(), makeImagePrototype(resources.openCoachDashboard()))); new ImageSpec(ACTION_OPEN_COACH_DASHBOARD, stringMessages.actionOpenDashboard(), makeImagePrototype(resources.openCoachDashboard())),
new ImageSpec(ACTION_SHOW_REGATTA_LOG, stringMessages.regattaLog(), makeImagePrototype(resources.flagIcon())));
} }
} }
@@ -261,6 +261,8 @@ TrackedRaceChangedListener, LeaderboardsDisplayer {
Map<String, String> dashboardURLParameters = new HashMap<String, String>(); Map<String, String> dashboardURLParameters = new HashMap<String, String>();
dashboardURLParameters.put("leaderboardName", leaderboardDTO.name); dashboardURLParameters.put("leaderboardName", leaderboardDTO.name);
Window.open(EntryPointLinkFactory.createDashboardLink(dashboardURLParameters), "", null); Window.open(EntryPointLinkFactory.createDashboardLink(dashboardURLParameters), "", null);
} else if (LeaderboardConfigImagesBarCell.ACTION_SHOW_REGATTA_LOG.equals(value)) {
showRegattaLog();
} }
} }
}); });
@@ -1,62 +1,26 @@
package com.sap.sailing.gwt.ui.adminconsole; package com.sap.sailing.gwt.ui.adminconsole;
import java.util.Comparator; import java.util.Comparator;
import java.util.Date;
import com.google.gwt.core.client.GWT;
import com.google.gwt.user.cellview.client.CellTable; import com.google.gwt.user.cellview.client.CellTable;
import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler; import com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler;
import com.google.gwt.user.cellview.client.TextColumn; import com.google.gwt.user.cellview.client.TextColumn;
import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ScrollPanel;
import com.google.gwt.user.client.ui.VerticalPanel; import com.google.gwt.user.client.ui.VerticalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.view.client.ListDataProvider;
import com.google.gwt.view.client.SelectionModel;
import com.google.gwt.view.client.SingleSelectionModel;
import com.sap.sailing.domain.common.impl.NaturalComparator;
import com.sap.sailing.gwt.ui.client.StringMessages; import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.common.client.DateAndTimeFormatterUtil;
import com.sap.sailing.gwt.ui.shared.RaceLogDTO; import com.sap.sailing.gwt.ui.shared.RaceLogDTO;
import com.sap.sailing.gwt.ui.shared.RaceLogEventDTO; import com.sap.sailing.gwt.ui.shared.RaceLogEventDTO;
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
public class RaceLogDialog extends DataEntryDialog<RaceLogDTO> { public class RaceLogDialog extends AbstractLogDialog<RaceLogDTO, RaceLogEventDTO> {
private final StringMessages stringMessages; private final StringMessages stringMessages;
private final RaceLogDTO raceLogDTO;
private final SelectionModel<RaceLogEventDTO> selectionModel; public RaceLogDialog(final RaceLogDTO raceLogDTO, final StringMessages stringMessages, DialogCallback<RaceLogDTO> callback) {
private final CellTable<RaceLogEventDTO> raceLogEventsTable; super(raceLogDTO, stringMessages, stringMessages.raceLog(), callback);
private ListDataProvider<RaceLogEventDTO> raceLogEventsList; this.stringMessages = stringMessages;
protected static class RaceLogValidator implements Validator<RaceLogDTO> {
public RaceLogValidator() {
super();
} }
@Override @Override
public String getErrorMessage(RaceLogDTO valueToValidate) { protected void addFirstColumns(CellTable<RaceLogEventDTO> table, ListHandler<RaceLogEventDTO> columnSortHandler) {
return null;
}
}
public RaceLogDialog(final RaceLogDTO raceLogDTO, final StringMessages stringMessages, DialogCallback<RaceLogDTO> callback) {
super(stringMessages.raceLog(), null, stringMessages.ok(), stringMessages.cancel(), new RaceLogValidator(), callback);
this.stringMessages = stringMessages;
this.raceLogDTO = raceLogDTO;
raceLogEventsList = new ListDataProvider<RaceLogEventDTO>();
selectionModel = new SingleSelectionModel<RaceLogEventDTO>();
AdminConsoleTableResources tableRes = GWT.create(AdminConsoleTableResources.class);
raceLogEventsTable = new CellTable<RaceLogEventDTO>(/* pageSize */10000, tableRes);
raceLogEventsTable.ensureDebugId("TrackedRacesTable");
raceLogEventsTable.setSelectionModel(selectionModel);
raceLogEventsList.setList(raceLogDTO.getEntries());
ListHandler<RaceLogEventDTO> columnSortHandler = new ListHandler<RaceLogEventDTO>(raceLogEventsList.getList());
raceLogEventsTable.addColumnSortHandler(columnSortHandler);
TextColumn<RaceLogEventDTO> raceLogEventPassIdColumn = new TextColumn<RaceLogEventDTO>() { TextColumn<RaceLogEventDTO> raceLogEventPassIdColumn = new TextColumn<RaceLogEventDTO>() {
@Override @Override
public String getValue(RaceLogEventDTO raceLogEventDTO) { public String getValue(RaceLogEventDTO raceLogEventDTO) {
@@ -70,117 +34,12 @@ public class RaceLogDialog extends DataEntryDialog<RaceLogDTO> {
return (r1.getPassId()<r2.getPassId() ? -1 : (r1.getPassId()==r2.getPassId() ? 0 : 1)); return (r1.getPassId()<r2.getPassId() ? -1 : (r1.getPassId()==r2.getPassId() ? 0 : 1));
} }
}); });
table.addColumn(raceLogEventPassIdColumn, "PassId");
TextColumn<RaceLogEventDTO> raceLogEventAuthorColumn = new TextColumn<RaceLogEventDTO>() {
@Override
public String getValue(RaceLogEventDTO raceLogEventDTO) {
return String.valueOf(raceLogEventDTO.getAuthorName());
}
};
TextColumn<RaceLogEventDTO> raceLogEventAuthorPriorityColumn = new TextColumn<RaceLogEventDTO>() {
@Override
public String getValue(RaceLogEventDTO raceLogEventDTO) {
return String.valueOf(raceLogEventDTO.getAuthorPriority());
}
};
TextColumn<RaceLogEventDTO> raceLogEventCreatedColumn = new TextColumn<RaceLogEventDTO>() {
@Override
public String getValue(RaceLogEventDTO raceLogEventDTO) {
Date createdAt = raceLogEventDTO.getCreatedAt();
if(createdAt != null) {
return DateAndTimeFormatterUtil.defaultDateFormatter.render(createdAt) + " " +
DateAndTimeFormatterUtil.defaultTimeFormatter.render(createdAt);
}
return "";
}
};
raceLogEventCreatedColumn.setSortable(true);
columnSortHandler.setComparator(raceLogEventCreatedColumn, new Comparator<RaceLogEventDTO>() {
@Override
public int compare(RaceLogEventDTO r1, RaceLogEventDTO r2) {
if (r1.getCreatedAt() != null && r2.getCreatedAt() != null) {
return r1.getCreatedAt().compareTo(r2.getCreatedAt());
}
return r1.getCreatedAt() == null ? (r2.getCreatedAt() == null ? 0 : -1) : 1;
}
});
TextColumn<RaceLogEventDTO> raceLogEventLogicalTimeColumn = new TextColumn<RaceLogEventDTO>() {
@Override
public String getValue(RaceLogEventDTO raceLogEventDTO) {
Date logicalTimePoint = raceLogEventDTO.getLogicalTimePoint();
if(logicalTimePoint != null) {
return DateAndTimeFormatterUtil.defaultDateFormatter.render(logicalTimePoint) + " " +
DateAndTimeFormatterUtil.defaultTimeFormatter.render(logicalTimePoint);
}
return "";
}
};
raceLogEventLogicalTimeColumn.setSortable(true);
columnSortHandler.setComparator(raceLogEventCreatedColumn, new Comparator<RaceLogEventDTO>() {
@Override
public int compare(RaceLogEventDTO r1, RaceLogEventDTO r2) {
if (r1.getLogicalTimePoint() != null && r2.getLogicalTimePoint() != null) {
return r1.getLogicalTimePoint().compareTo(r2.getLogicalTimePoint());
}
return r1.getLogicalTimePoint() == null ? (r2.getLogicalTimePoint() == null ? 0 : -1) : 1;
}
});
TextColumn<RaceLogEventDTO> raceLogEventTypeColumn = new TextColumn<RaceLogEventDTO>() {
@Override
public String getValue(RaceLogEventDTO raceLogEventDTO) {
return raceLogEventDTO.getType();
}
};
raceLogEventTypeColumn.setSortable(true);
columnSortHandler.setComparator(raceLogEventTypeColumn, new Comparator<RaceLogEventDTO>() {
@Override
public int compare(RaceLogEventDTO r1, RaceLogEventDTO r2) {
return new NaturalComparator().compare(r1.getType(), r2.getType());
}
});
TextColumn<RaceLogEventDTO> raceLogEventInfoColumn = new TextColumn<RaceLogEventDTO>() {
@Override
public String getValue(RaceLogEventDTO raceLogEventDTO) {
return raceLogEventDTO.getInfo();
}
};
raceLogEventsTable.addColumn(raceLogEventPassIdColumn, "PassId");
raceLogEventsTable.addColumn(raceLogEventTypeColumn, stringMessages.type());
raceLogEventsTable.addColumn(raceLogEventCreatedColumn, "Created at");
raceLogEventsTable.addColumn(raceLogEventLogicalTimeColumn, "Logical timepoint");
raceLogEventsTable.addColumn(raceLogEventAuthorColumn, "Author");
raceLogEventsTable.addColumn(raceLogEventAuthorPriorityColumn, "Priority");
raceLogEventsTable.addColumn(raceLogEventInfoColumn, "Info");
raceLogEventsList.addDataDisplay(raceLogEventsTable);
raceLogEventsTable.getColumnSortList().push(raceLogEventLogicalTimeColumn);
} }
@Override @Override
protected RaceLogDTO getResult() { protected void addFirstWidgetComponents(VerticalPanel vPanel) {
return null; Label currentPassLabel = new Label(stringMessages.currentPass() + ":" + getLogDTO().getCurrentPassId());
}
@Override
protected Widget getAdditionalWidget() {
VerticalPanel vPanel = new VerticalPanel();
Label currentPassLabel = new Label(stringMessages.currentPass() + ":" + raceLogDTO.getCurrentPassId());
vPanel.add(currentPassLabel); vPanel.add(currentPassLabel);
ScrollPanel scrollPanel = new ScrollPanel(raceLogEventsTable);
scrollPanel.setSize("960px", "500px");
vPanel.add(scrollPanel);
return vPanel;
} }
} }
@@ -12,6 +12,7 @@ public class RaceLogTrackingEventManagementImagesBarCell extends ImagesBarCell {
public final static String ACTION_COMPETITOR_REGISTRATIONS = "ACTION_COMPETITOR_REGISTRATIONS"; public final static String ACTION_COMPETITOR_REGISTRATIONS = "ACTION_COMPETITOR_REGISTRATIONS";
public final static String ACTION_MAP_DEVICES = "ACTION_MAP_DEVICES"; public final static String ACTION_MAP_DEVICES = "ACTION_MAP_DEVICES";
public final static String ACTION_INVITE_BUOY_TENDERS = "ACTION_INVITE_BUOY_TENDERS"; public final static String ACTION_INVITE_BUOY_TENDERS = "ACTION_INVITE_BUOY_TENDERS";
public static final String ACTION_SHOW_REGATTA_LOG = "ACTION_SHOW_REGATTA_LOG";
private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class); private static AdminConsoleResources resources = GWT.create(AdminConsoleResources.class);
private final StringMessages stringMessages; private final StringMessages stringMessages;
@@ -37,6 +38,8 @@ public class RaceLogTrackingEventManagementImagesBarCell extends ImagesBarCell {
makeImagePrototype(resources.mapDevices()))); makeImagePrototype(resources.mapDevices())));
result.add(new ImageSpec(ACTION_INVITE_BUOY_TENDERS, stringMessages.inviteBuoyTenders(), result.add(new ImageSpec(ACTION_INVITE_BUOY_TENDERS, stringMessages.inviteBuoyTenders(),
makeImagePrototype(resources.inviteBuoyTenders()))); makeImagePrototype(resources.inviteBuoyTenders())));
result.add(new ImageSpec(ACTION_SHOW_REGATTA_LOG, stringMessages.regattaLog(),
makeImagePrototype(resources.flagIcon())));
return result; return result;
} }
@@ -140,6 +140,8 @@ public class RaceLogTrackingEventManagementPanel extends AbstractLeaderboardConf
leaderboardName).show(); leaderboardName).show();
} else if (RaceLogTrackingEventManagementImagesBarCell.ACTION_INVITE_BUOY_TENDERS.equals(value)) { } else if (RaceLogTrackingEventManagementImagesBarCell.ACTION_INVITE_BUOY_TENDERS.equals(value)) {
openChooseEventDialogAndSendMails(leaderboardName); openChooseEventDialogAndSendMails(leaderboardName);
} else if (RaceLogTrackingEventManagementImagesBarCell.ACTION_SHOW_REGATTA_LOG.equals(value)) {
showRegattaLog();
} }
} }
}); });
@@ -0,0 +1,11 @@
package com.sap.sailing.gwt.ui.adminconsole;
import com.sap.sailing.gwt.ui.client.StringMessages;
import com.sap.sailing.gwt.ui.shared.RegattaLogDTO;
import com.sap.sailing.gwt.ui.shared.RegattaLogEventDTO;
public class RegattaLogDialog extends AbstractLogDialog<RegattaLogDTO, RegattaLogEventDTO> {
public RegattaLogDialog(final RegattaLogDTO regattaLogDTO, final StringMessages stringMessages, DialogCallback<RegattaLogDTO> callback) {
super(regattaLogDTO, stringMessages, stringMessages.raceLog(), callback);
}
}
@@ -66,6 +66,7 @@ import com.sap.sailing.gwt.ui.shared.RaceLogDTO;
import com.sap.sailing.gwt.ui.shared.RaceLogSetStartTimeAndProcedureDTO; import com.sap.sailing.gwt.ui.shared.RaceLogSetStartTimeAndProcedureDTO;
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO; import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
import com.sap.sailing.gwt.ui.shared.RegattaDTO; import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sailing.gwt.ui.shared.RegattaLogDTO;
import com.sap.sailing.gwt.ui.shared.RegattaOverviewEntryDTO; import com.sap.sailing.gwt.ui.shared.RegattaOverviewEntryDTO;
import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO; import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO;
import com.sap.sailing.gwt.ui.shared.RemoteSailingServerReferenceDTO; import com.sap.sailing.gwt.ui.shared.RemoteSailingServerReferenceDTO;
@@ -397,6 +398,8 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
RaceLogDTO getRaceLog(String leaderboardName, RaceColumnDTO raceColumnDTO, FleetDTO fleet); RaceLogDTO getRaceLog(String leaderboardName, RaceColumnDTO raceColumnDTO, FleetDTO fleet);
RegattaLogDTO getRegattaLog(String leaderboardName) throws DoesNotHaveRegattaLogException;
List<String> getLeaderboardGroupNamesFromRemoteServer(String host); List<String> getLeaderboardGroupNamesFromRemoteServer(String host);
UUID importMasterData(String host, String[] groupNames, boolean override, boolean compress, boolean exportWind); UUID importMasterData(String host, String[] groupNames, boolean override, boolean compress, boolean exportWind);
@@ -586,4 +589,5 @@ public interface SailingService extends RemoteService, FileStorageManagementGwtS
void inviteBuoyTenderViaEmail(String serverUrlWithoutTrailingSlash, EventDTO eventDto, String leaderboardName, void inviteBuoyTenderViaEmail(String serverUrlWithoutTrailingSlash, EventDTO eventDto, String leaderboardName,
String emails, String localeInfoName) throws MailException; String emails, String localeInfoName) throws MailException;
} }
@@ -56,6 +56,7 @@ import com.sap.sailing.gwt.ui.shared.RaceLogDTO;
import com.sap.sailing.gwt.ui.shared.RaceLogSetStartTimeAndProcedureDTO; import com.sap.sailing.gwt.ui.shared.RaceLogSetStartTimeAndProcedureDTO;
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO; import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
import com.sap.sailing.gwt.ui.shared.RegattaDTO; import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sailing.gwt.ui.shared.RegattaLogDTO;
import com.sap.sailing.gwt.ui.shared.RegattaOverviewEntryDTO; import com.sap.sailing.gwt.ui.shared.RegattaOverviewEntryDTO;
import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO; import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO;
import com.sap.sailing.gwt.ui.shared.RemoteSailingServerReferenceDTO; import com.sap.sailing.gwt.ui.shared.RemoteSailingServerReferenceDTO;
@@ -506,8 +507,9 @@ public interface SailingServiceAsync extends BuildVersionRetriever, FileStorageM
void getRaceLog(String leaderboardName, RaceColumnDTO raceColumnDTO, FleetDTO fleet, void getRaceLog(String leaderboardName, RaceColumnDTO raceColumnDTO, FleetDTO fleet,
AsyncCallback<RaceLogDTO> callback); AsyncCallback<RaceLogDTO> callback);
void importMasterData(String host, String[] names, boolean override, boolean compress, void getRegattaLog(String leaderboardName, AsyncCallback<RegattaLogDTO> callback);
boolean exportWind,
void importMasterData(String host, String[] names, boolean override, boolean compress, boolean exportWind,
AsyncCallback<UUID> asyncCallback); AsyncCallback<UUID> asyncCallback);
void getImportOperationProgress(UUID id, AsyncCallback<DataImportProgress> asyncCallback); void getImportOperationProgress(UUID id, AsyncCallback<DataImportProgress> asyncCallback);
@@ -693,4 +695,5 @@ public interface SailingServiceAsync extends BuildVersionRetriever, FileStorageM
void inviteBuoyTenderViaEmail(String serverUrlWithoutTrailingSlash, EventDTO eventDto, String leaderboardName, void inviteBuoyTenderViaEmail(String serverUrlWithoutTrailingSlash, EventDTO eventDto, String leaderboardName,
String emails, String localeInfoName, AsyncCallback<Void> callback); String emails, String localeInfoName, AsyncCallback<Void> callback);
} }
@@ -754,6 +754,7 @@ public interface StringMessages extends com.sap.sse.gwt.client.StringMessages, c
String protestEndsAt(); String protestEndsAt();
String unknown(); String unknown();
String raceLog(); String raceLog();
String regattaLog();
String refreshRaceLog(); String refreshRaceLog();
String raceLogReloaded(); String raceLogReloaded();
String reloadAllRaceLogs(); String reloadAllRaceLogs();
@@ -748,6 +748,7 @@ protestEndsAt=Protest ends at
unknown=Unknown unknown=Unknown
earlyStarters=Early starters earlyStarters=Early starters
raceLog=Race log raceLog=Race log
regattaLog=Regatta log
refreshRaceLog=Refresh race log refreshRaceLog=Refresh race log
raceLogReloaded=Race log successfully reloaded from database raceLogReloaded=Race log successfully reloaded from database
reloadAllRaceLogs=Reload all race logs reloadAllRaceLogs=Reload all race logs
@@ -744,6 +744,7 @@ protestEndsAt=Protestzeit endet
unknown=Unbekannt unknown=Unbekannt
earlyStarters=Frühstarter earlyStarters=Frühstarter
raceLog=RaceLog raceLog=RaceLog
regattaLog=RegattaLog
refreshRaceLog=RaceLog neu laden refreshRaceLog=RaceLog neu laden
raceLogReloaded=RaceLog wurde neu geladen raceLogReloaded=RaceLog wurde neu geladen
reloadAllRaceLogs=Alle RaceLogs neu laden reloadAllRaceLogs=Alle RaceLogs neu laden
@@ -738,6 +738,7 @@ protestEndsAt=Срок подачи протеста завершается в
unknown=Неизвестно unknown=Неизвестно
earlyStarters=Совершивших фальшстарт earlyStarters=Совершивших фальшстарт
raceLog=Запись о гонке raceLog=Запись о гонке
regattaLog=Regatta log
refreshRaceLog=Обновить запись о гонке refreshRaceLog=Обновить запись о гонке
raceLogReloaded=Запись о гонке успешно повторно загружена из базы данных raceLogReloaded=Запись о гонке успешно повторно загружена из базы данных
reloadAllRaceLogs=Повторно загрузить все записи о гонке reloadAllRaceLogs=Повторно загрузить все записи о гонке
@@ -74,6 +74,7 @@ import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.DefinedMa
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceLogOpenEndedDeviceMappingCloser; import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceLogOpenEndedDeviceMappingCloser;
import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceLogTrackingStateAnalyzer; import com.sap.sailing.domain.abstractlog.race.tracking.analyzing.impl.RaceLogTrackingStateAnalyzer;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLog; import com.sap.sailing.domain.abstractlog.regatta.RegattaLog;
import com.sap.sailing.domain.abstractlog.regatta.RegattaLogEvent;
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceCompetitorMappingFinder; import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceCompetitorMappingFinder;
import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceMarkMappingFinder; import com.sap.sailing.domain.abstractlog.shared.analyzing.DeviceMarkMappingFinder;
import com.sap.sailing.domain.abstractlog.shared.analyzing.RegisteredCompetitorsAnalyzer; import com.sap.sailing.domain.abstractlog.shared.analyzing.RegisteredCompetitorsAnalyzer;
@@ -301,6 +302,8 @@ import com.sap.sailing.gwt.ui.shared.RaceMapDataDTO;
import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO; import com.sap.sailing.gwt.ui.shared.RaceTimesInfoDTO;
import com.sap.sailing.gwt.ui.shared.RaceWithCompetitorsDTO; import com.sap.sailing.gwt.ui.shared.RaceWithCompetitorsDTO;
import com.sap.sailing.gwt.ui.shared.RegattaDTO; import com.sap.sailing.gwt.ui.shared.RegattaDTO;
import com.sap.sailing.gwt.ui.shared.RegattaLogDTO;
import com.sap.sailing.gwt.ui.shared.RegattaLogEventDTO;
import com.sap.sailing.gwt.ui.shared.RegattaOverviewEntryDTO; import com.sap.sailing.gwt.ui.shared.RegattaOverviewEntryDTO;
import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO; import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO;
import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO.ScoreCorrectionEntryDTO; import com.sap.sailing.gwt.ui.shared.RegattaScoreCorrectionDTO.ScoreCorrectionEntryDTO;
@@ -4251,6 +4254,30 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
return result; return result;
} }
@Override
public RegattaLogDTO getRegattaLog(String leaderboardName) throws DoesNotHaveRegattaLogException {
RegattaLogDTO result = null;
RegattaLog regattaLog = getRegattaLogInternal(leaderboardName);
if (regattaLog != null) {
List<RegattaLogEventDTO> entries = new ArrayList<>();
result = new RegattaLogDTO(leaderboardName, entries);
regattaLog.lockForRead();
try {
for(RegattaLogEvent raceLogEvent: regattaLog.getRawFixes()) {
RegattaLogEventDTO entry = new RegattaLogEventDTO(
raceLogEvent.getAuthor().getName(), raceLogEvent.getAuthor().getPriority(),
raceLogEvent.getCreatedAt() != null ? raceLogEvent.getCreatedAt().asDate() : null,
raceLogEvent.getLogicalTimePoint() != null ? raceLogEvent.getLogicalTimePoint().asDate() : null,
raceLogEvent.getClass().getSimpleName(), raceLogEvent.getShortInfo());
entries.add(entry);
}
} finally {
regattaLog.unlockAfterRead();
}
}
return result;
}
@Override @Override
public List<String> getLeaderboardGroupNamesFromRemoteServer(String url) { public List<String> getLeaderboardGroupNamesFromRemoteServer(String url) {
com.sap.sse.common.Util.Pair<String, Integer> hostnameAndPort = parseHostAndPort(url); com.sap.sse.common.Util.Pair<String, Integer> hostnameAndPort = parseHostAndPort(url);
@@ -4818,7 +4845,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
return getRaceLog(triple.getA(), triple.getB(), triple.getC()); return getRaceLog(triple.getA(), triple.getB(), triple.getC());
} }
private RegattaLog getRegattaLog(String leaderboardName) throws DoesNotHaveRegattaLogException { private RegattaLog getRegattaLogInternal(String leaderboardName) throws DoesNotHaveRegattaLogException {
Leaderboard l = getService().getLeaderboardByName(leaderboardName); Leaderboard l = getService().getLeaderboardByName(leaderboardName);
if (! (l instanceof HasRegattaLike)) { if (! (l instanceof HasRegattaLike)) {
throw new DoesNotHaveRegattaLogException(); throw new DoesNotHaveRegattaLogException();
@@ -4844,7 +4871,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
throws DoesNotHaveRegattaLogException { throws DoesNotHaveRegattaLogException {
return convertToCompetitorDTOs( return convertToCompetitorDTOs(
new RegisteredCompetitorsAnalyzer<>( new RegisteredCompetitorsAnalyzer<>(
getRegattaLog(leaderboardName)).analyze()); getRegattaLogInternal(leaderboardName)).analyze());
} }
private Competitor getCompetitor(CompetitorDTO dto) { private Competitor getCompetitor(CompetitorDTO dto) {
@@ -4866,7 +4893,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
@Override @Override
public void setCompetitorRegistrations(String leaderboardName, Set<CompetitorDTO> competitorDTOs) public void setCompetitorRegistrations(String leaderboardName, Set<CompetitorDTO> competitorDTOs)
throws DoesNotHaveRegattaLogException { throws DoesNotHaveRegattaLogException {
RegattaLog regattaLog = getRegattaLog(leaderboardName); RegattaLog regattaLog = getRegattaLogInternal(leaderboardName);
Set<Competitor> competitors = new HashSet<Competitor>(); Set<Competitor> competitors = new HashSet<Competitor>();
for (CompetitorDTO dto : competitorDTOs) { for (CompetitorDTO dto : competitorDTOs) {
competitors.add(getCompetitor(dto)); competitors.add(getCompetitor(dto));
@@ -0,0 +1,28 @@
package com.sap.sailing.gwt.ui.shared;
import java.util.List;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* DTO for a race log with all raw race log entries
*/
public class AbstractLogDTO<E extends AbstractLogEventDTO> implements IsSerializable {
private String leaderboardName;
private List<E> entries;
AbstractLogDTO() {}
public AbstractLogDTO(String leaderboardName, List<E> entries) {
this.leaderboardName = leaderboardName;
this.entries = entries;
}
public String getLeaderboardName() {
return leaderboardName;
}
public List<E> getEntries() {
return entries;
}
}
@@ -0,0 +1,64 @@
package com.sap.sailing.gwt.ui.shared;
import java.util.Date;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* DTO for a race log entry.
*/
public class AbstractLogEventDTO implements IsSerializable {
private String authorName;
private Integer authorPriority;
private Date createdAt;
private Date logicalTimePoint;
/** RaceLogEvent.getClass().getSimpleName() */
private String type;
/** RaceLogEvent.toString() */
private String info;
AbstractLogEventDTO() {}
public AbstractLogEventDTO(String authorName, Integer authorPriority, Date createdAt, Date logicalTimePoint,
String type, String info) {
this.authorName = authorName;
this.authorPriority = authorPriority;
this.createdAt = createdAt;
this.logicalTimePoint = logicalTimePoint;
this.type = type;
this.info = info;
}
public String getAuthorName() {
return authorName;
}
public Integer getAuthorPriority() {
return authorPriority;
}
public Date getLogicalTimePoint() {
return logicalTimePoint;
}
public String getType() {
String result = type;
if(result.startsWith("RaceLog")) {
result = result.substring("RaceLog".length(), result.length());
}
if(result.endsWith("EventImpl")) {
result = result.substring(0, result.length()- "EventImpl".length());
}
return result;
}
public String getInfo() {
return info;
}
public Date getCreatedAt() {
return createdAt;
}
}
@@ -7,25 +7,18 @@ import com.google.gwt.user.client.rpc.IsSerializable;
/** /**
* DTO for a race log with all raw race log entries * DTO for a race log with all raw race log entries
*/ */
public class RaceLogDTO implements IsSerializable { public class RaceLogDTO extends AbstractLogDTO<RaceLogEventDTO> implements IsSerializable {
private String leaderboardName;
private String raceColumnName; private String raceColumnName;
private String fleetName; private String fleetName;
private Integer currentPassId; private Integer currentPassId;
private List<RaceLogEventDTO> entries;
RaceLogDTO() {} RaceLogDTO() {}
public RaceLogDTO(String leaderboardName, String raceColumnName, String fleetName, Integer currentPassId, List<RaceLogEventDTO> entries) { public RaceLogDTO(String leaderboardName, String raceColumnName, String fleetName, Integer currentPassId, List<RaceLogEventDTO> entries) {
this.leaderboardName = leaderboardName; super(leaderboardName, entries);
this.raceColumnName = raceColumnName; this.raceColumnName = raceColumnName;
this.fleetName = fleetName; this.fleetName = fleetName;
this.currentPassId = currentPassId; this.currentPassId = currentPassId;
this.entries = entries;
}
public String getLeaderboardName() {
return leaderboardName;
} }
public String getRaceColumnName() { public String getRaceColumnName() {
@@ -36,10 +29,6 @@ public class RaceLogDTO implements IsSerializable {
return fleetName; return fleetName;
} }
public List<RaceLogEventDTO> getEntries() {
return entries;
}
public Integer getCurrentPassId() { public Integer getCurrentPassId() {
return currentPassId; return currentPassId;
} }
@@ -7,64 +7,18 @@ import com.google.gwt.user.client.rpc.IsSerializable;
/** /**
* DTO for a race log entry. * DTO for a race log entry.
*/ */
public class RaceLogEventDTO implements IsSerializable { public class RaceLogEventDTO extends AbstractLogEventDTO implements IsSerializable {
private Integer passId; private Integer passId;
private String authorName;
private Integer authorPriority;
private Date createdAt;
private Date logicalTimePoint;
/** RaceLogEvent.getClass().getSimpleName() */
private String type;
/** RaceLogEvent.toString() */
private String info;
RaceLogEventDTO() {} RaceLogEventDTO() {}
public RaceLogEventDTO(int passId, String authorName, Integer authorPriority, Date createdAt, Date logicalTimePoint, public RaceLogEventDTO(int passId, String authorName, Integer authorPriority, Date createdAt, Date logicalTimePoint,
String type, String info) { String type, String info) {
super(authorName, authorPriority, createdAt, logicalTimePoint, type, info);
this.passId = passId; this.passId = passId;
this.authorName = authorName;
this.authorPriority = authorPriority;
this.createdAt = createdAt;
this.logicalTimePoint = logicalTimePoint;
this.type = type;
this.info = info;
} }
public int getPassId() { public int getPassId() {
return passId; return passId;
} }
public String getAuthorName() {
return authorName;
}
public Integer getAuthorPriority() {
return authorPriority;
}
public Date getLogicalTimePoint() {
return logicalTimePoint;
}
public String getType() {
String result = type;
if(result.startsWith("RaceLog")) {
result = result.substring("RaceLog".length(), result.length());
}
if(result.endsWith("EventImpl")) {
result = result.substring(0, result.length()- "EventImpl".length());
}
return result;
}
public String getInfo() {
return info;
}
public Date getCreatedAt() {
return createdAt;
}
} }
@@ -0,0 +1,16 @@
package com.sap.sailing.gwt.ui.shared;
import java.util.List;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* DTO for a race log with all raw race log entries
*/
public class RegattaLogDTO extends AbstractLogDTO<RegattaLogEventDTO> implements IsSerializable {
RegattaLogDTO() {}
public RegattaLogDTO(String leaderboardName, List<RegattaLogEventDTO> entries) {
super(leaderboardName, entries);
}
}
@@ -0,0 +1,17 @@
package com.sap.sailing.gwt.ui.shared;
import java.util.Date;
import com.google.gwt.user.client.rpc.IsSerializable;
/**
* DTO for a race log entry.
*/
public class RegattaLogEventDTO extends AbstractLogEventDTO implements IsSerializable {
RegattaLogEventDTO() {}
public RegattaLogEventDTO(String authorName, Integer authorPriority, Date createdAt, Date logicalTimePoint,
String type, String info) {
super(authorName, authorPriority, createdAt, logicalTimePoint, type, info);
}
}
@@ -88,13 +88,8 @@ public class WindInfoForRaceVectorField implements VectorField, AverageLatitudeP
return true; return true;
} }
private final static Position where = new DegreePosition(-33.85741596360764,151.22181591282387);
@Override @Override
public Vector getVector(Position p, Date at) { public Vector getVector(Position p, Date at) {
if (where.getDistance(p).getMeters() < 50) {
System.out.println("Here we are");
}
final PositionDTO request = new PositionDTO(p.getLatDeg(), p.getLngDeg()); final PositionDTO request = new PositionDTO(p.getLatDeg(), p.getLngDeg());
double speedConfidenceSum = 0; double speedConfidenceSum = 0;
double knotSpeedSumScaledByConfidence = 0; double knotSpeedSumScaledByConfidence = 0;
@@ -171,7 +166,7 @@ public class WindInfoForRaceVectorField implements VectorField, AverageLatitudeP
// and where null is returned when there is no fix at the rounded time point; mimic this behavior here. See // and where null is returned when there is no fix at the rounded time point; mimic this behavior here. See
// also bug 2689 comment #13. // also bug 2689 comment #13.
if (windTrackInfo.resolutionOutsideOfWhichNoFixWillBeReturned != null) { if (windTrackInfo.resolutionOutsideOfWhichNoFixWillBeReturned != null) {
if (Math.abs(preResult.requestTimepoint-at.getTime()) > windTrackInfo.resolutionOutsideOfWhichNoFixWillBeReturned.asMillis()) { if (preResult == null || Math.abs(preResult.requestTimepoint-at.getTime()) > windTrackInfo.resolutionOutsideOfWhichNoFixWillBeReturned.asMillis()) {
result = null; result = null;
} else { } else {
result = preResult; result = preResult;