mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-11 23:00:59 +00:00
removed overly redundant repitition of Marks in the RaceCourseDTO and nested DTOs
This commit is contained in:
1 parent
4dc1ae1ea1
commit
c9bfef9848
5 files changed
+36
-49
No files matched your search
+1
-1
@@ -112,7 +112,7 @@ public abstract class CourseManagementWidget implements IsWidget {
|
||||
WaypointDTO waypoint = waypoints.getSelectionModel().getSelectedObject();
|
||||
if (waypoint != null) {
|
||||
selectControlPoints(waypoint);
|
||||
selectMarks(waypoint.marks);
|
||||
selectMarks(waypoint.controlPoint.getMarks());
|
||||
}
|
||||
updateWaypointButtons();
|
||||
}
|
||||
|
||||
+2
-6
@@ -1,6 +1,5 @@
|
||||
package com.sap.sailing.gwt.ui.adminconsole;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.google.gwt.user.client.ui.Grid;
|
||||
@@ -9,15 +8,14 @@ import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.ListBox;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.google.gwt.view.client.SelectionChangeEvent.Handler;
|
||||
import com.google.gwt.view.client.SingleSelectionModel;
|
||||
import com.sap.sailing.domain.common.PassingInstruction;
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
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.ControlPointDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.MarkDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.WaypointDTO;
|
||||
import com.sap.sse.gwt.client.dialog.DataEntryDialog;
|
||||
|
||||
@@ -83,13 +81,11 @@ public class WaypointCreationDialog extends DataEntryDialog<WaypointDTO> {
|
||||
: PassingInstruction.None;
|
||||
|
||||
ControlPointDTO controlPoint = controlPointsWrapper.getSelectionModel().getSelectedObject();
|
||||
List<MarkDTO> marks = new ArrayList<MarkDTO>();
|
||||
String name = null;
|
||||
if (controlPoint != null) {
|
||||
Util.addAll(controlPoint.getMarks(), marks);
|
||||
name = controlPoint.getName();
|
||||
}
|
||||
return new WaypointDTO(name, controlPoint, marks, pi);
|
||||
return new WaypointDTO(name, controlPoint, pi);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+20
-29
@@ -882,11 +882,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
List<WaypointDTO> waypointDTOs = new ArrayList<WaypointDTO>();
|
||||
for (Waypoint waypoint : lastCourseDesign.getWaypoints()) {
|
||||
ControlPointDTO controlPointDTO = convertToControlPointDTO(waypoint.getControlPoint());
|
||||
List<MarkDTO> marks = new ArrayList<MarkDTO>();
|
||||
for (MarkDTO markDTO : controlPointDTO.getMarks()) {
|
||||
marks.add(markDTO);
|
||||
}
|
||||
WaypointDTO waypointDTO = new WaypointDTO(waypoint.getName(), controlPointDTO, marks, waypoint.getPassingInstructions());
|
||||
WaypointDTO waypointDTO = new WaypointDTO(waypoint.getName(), controlPointDTO, waypoint.getPassingInstructions());
|
||||
waypointDTOs.add(waypointDTO);
|
||||
}
|
||||
result = new RaceCourseDTO(waypointDTOs);
|
||||
@@ -1633,30 +1629,27 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
public RaceCourseDTO getRaceCourse(RegattaAndRaceIdentifier raceIdentifier, Date date) {
|
||||
List<WaypointDTO> waypointDTOs = new ArrayList<WaypointDTO>();
|
||||
Map<Serializable, ControlPointDTO> controlPointCache = new HashMap<>();
|
||||
RaceCourseDTO result = new RaceCourseDTO(waypointDTOs);
|
||||
if (date != null) {
|
||||
TimePoint dateAsTimePoint = new MillisecondsTimePoint(date);
|
||||
TrackedRace trackedRace = getExistingTrackedRace(raceIdentifier);
|
||||
if (trackedRace != null) {
|
||||
Course course = trackedRace.getRace().getCourse();
|
||||
for (Waypoint waypoint : course.getWaypoints()) {
|
||||
List<MarkDTO> marks = new ArrayList<>();
|
||||
for (Mark mark : waypoint.getMarks()) {
|
||||
GPSFixTrack<Mark, GPSFix> track = trackedRace.getOrCreateTrack(mark);
|
||||
Position positionAtDate = track.getEstimatedPosition(dateAsTimePoint, /* extrapolate */false);
|
||||
marks.add(convertToMarkDTO(mark, positionAtDate));
|
||||
}
|
||||
ControlPointDTO controlPointDTO = controlPointCache.get(waypoint.getControlPoint().getId());
|
||||
if (controlPointDTO == null) {
|
||||
controlPointDTO = convertToControlPointDTO(waypoint.getControlPoint(), trackedRace, dateAsTimePoint);
|
||||
controlPointCache.put(waypoint.getControlPoint().getId(), controlPointDTO);
|
||||
}
|
||||
WaypointDTO waypointDTO = new WaypointDTO(waypoint.getName(), controlPointDTO, marks, waypoint.getPassingInstructions());
|
||||
waypointDTOs.add(waypointDTO);
|
||||
TimePoint dateAsTimePoint = new MillisecondsTimePoint(date);
|
||||
TrackedRace trackedRace = getExistingTrackedRace(raceIdentifier);
|
||||
List<MarkDTO> allMarks = new ArrayList<>();
|
||||
if (trackedRace != null) {
|
||||
for (Mark mark : trackedRace.getMarks()) {
|
||||
Position pos = trackedRace.getOrCreateTrack(mark).getEstimatedPosition(dateAsTimePoint, false);
|
||||
allMarks.add(convertToMarkDTO(mark, pos));
|
||||
}
|
||||
Course course = trackedRace.getRace().getCourse();
|
||||
for (Waypoint waypoint : course.getWaypoints()) {
|
||||
ControlPointDTO controlPointDTO = controlPointCache.get(waypoint.getControlPoint().getId());
|
||||
if (controlPointDTO == null) {
|
||||
controlPointDTO = convertToControlPointDTO(waypoint.getControlPoint(), trackedRace, dateAsTimePoint);
|
||||
controlPointCache.put(waypoint.getControlPoint().getId(), controlPointDTO);
|
||||
}
|
||||
WaypointDTO waypointDTO = new WaypointDTO(waypoint.getName(), controlPointDTO,
|
||||
waypoint.getPassingInstructions());
|
||||
waypointDTOs.add(waypointDTO);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return new RaceCourseDTO(waypointDTOs, allMarks);
|
||||
}
|
||||
|
||||
private ControlPointDTO convertToControlPointDTO(ControlPoint controlPoint, TrackedRace trackedRace, TimePoint timePoint) {
|
||||
@@ -4179,9 +4172,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S
|
||||
cp = convertToControlPointDTO(waypoint.getControlPoint());
|
||||
controlPointCache.put(waypoint.getControlPoint().getId(), cp);
|
||||
}
|
||||
List<MarkDTO> marks = new ArrayList<MarkDTO>();
|
||||
Util.addAll(cp.getMarks(), marks);
|
||||
return new WaypointDTO(waypoint.getName(), cp, marks, waypoint.getPassingInstructions());
|
||||
return new WaypointDTO(waypoint.getName(), cp, waypoint.getPassingInstructions());
|
||||
}
|
||||
|
||||
private RaceCourseDTO convertToRaceCourseDTO(CourseBase course) {
|
||||
|
||||
+12
-7
@@ -10,7 +10,12 @@ import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
public class RaceCourseDTO implements IsSerializable {
|
||||
public List<WaypointDTO> waypoints;
|
||||
public List<MarkDTO> marks;
|
||||
|
||||
/**
|
||||
* List of all marks in race, that can include such that are not actually part of
|
||||
* the race course definition.
|
||||
*/
|
||||
private List<MarkDTO> allMarks;
|
||||
|
||||
RaceCourseDTO() {
|
||||
}
|
||||
@@ -19,9 +24,9 @@ public class RaceCourseDTO implements IsSerializable {
|
||||
this(waypoints, null);
|
||||
}
|
||||
|
||||
public RaceCourseDTO(List<WaypointDTO> waypoints, List<MarkDTO> marks) {
|
||||
public RaceCourseDTO(List<WaypointDTO> waypoints, List<MarkDTO> allMarks) {
|
||||
this.waypoints = waypoints;
|
||||
this.marks = marks;
|
||||
this.allMarks = allMarks;
|
||||
}
|
||||
|
||||
public List<ControlPointDTO> getControlPoints() {
|
||||
@@ -33,13 +38,13 @@ public class RaceCourseDTO implements IsSerializable {
|
||||
}
|
||||
|
||||
public Collection<MarkDTO> getMarks() {
|
||||
final Collection<MarkDTO> result;
|
||||
if (marks != null) {
|
||||
result = marks;
|
||||
Collection<MarkDTO> result;
|
||||
if (allMarks != null) {
|
||||
result = allMarks;
|
||||
} else {
|
||||
Map<String, MarkDTO> marks = new HashMap<String, MarkDTO>();
|
||||
for (WaypointDTO waypoint : waypoints) {
|
||||
for (MarkDTO mark : waypoint.marks) {
|
||||
for (MarkDTO mark : waypoint.controlPoint.getMarks()) {
|
||||
if (!marks.containsKey(mark.getName())) {
|
||||
marks.put(mark.getName(), mark);
|
||||
}
|
||||
|
||||
+1
-6
@@ -1,7 +1,5 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.common.PassingInstruction;
|
||||
import com.sap.sailing.domain.common.dto.NamedDTO;
|
||||
|
||||
@@ -11,8 +9,6 @@ import com.sap.sailing.domain.common.dto.NamedDTO;
|
||||
*/
|
||||
public class WaypointDTO extends NamedDTO {
|
||||
private static final long serialVersionUID = 7439553659782967746L;
|
||||
|
||||
public List<MarkDTO> marks;
|
||||
|
||||
public ControlPointDTO controlPoint;
|
||||
|
||||
@@ -20,10 +16,9 @@ public class WaypointDTO extends NamedDTO {
|
||||
|
||||
WaypointDTO() {}
|
||||
|
||||
public WaypointDTO(String name, ControlPointDTO controlPoint, List<MarkDTO> marks, PassingInstruction passingInstructions) {
|
||||
public WaypointDTO(String name, ControlPointDTO controlPoint, PassingInstruction passingInstructions) {
|
||||
super(name);
|
||||
this.setName(name);
|
||||
this.marks = marks;
|
||||
this.controlPoint = controlPoint;
|
||||
this.passingInstructions = passingInstructions;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user