mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-05 11:53:53 +00:00
solving bug 2492 by cloning default structure RegattaDTO and adjusting by filling in some elements of the original regatta from the XRR document
This commit is contained in:
1 parent
4eecdc4b00
commit
c798f803ad
4 files changed
+32
-5
No files matched your search
+10
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
@@ -39,6 +40,7 @@ import com.sap.sailing.gwt.ui.shared.EventAndRegattaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.EventDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.LeaderboardGroupDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.RegattaDTO;
|
||||
import com.sap.sailing.gwt.ui.shared.SeriesDTO;
|
||||
import com.sap.sse.gwt.client.ErrorReporter;
|
||||
import com.sap.sse.gwt.client.controls.busyindicator.BusyIndicator;
|
||||
import com.sap.sse.gwt.client.controls.busyindicator.SimpleBusyIndicator;
|
||||
@@ -419,6 +421,14 @@ public class StructureImportManagementPanel extends FlowPanel implements Regatta
|
||||
RegattaDTO cloneFromDefaults = new RegattaDTO(regattaDefaultsPerStructure.get(regattaStructures.get(originalRegattaFromXRR)));
|
||||
cloneFromDefaults.setName(originalRegattaFromXRR.getName());
|
||||
cloneFromDefaults.boatClass = originalRegattaFromXRR.boatClass;
|
||||
// copy the race columns from original to clone of template
|
||||
Iterator<SeriesDTO> originalSeriesIter = originalRegattaFromXRR.series.iterator();
|
||||
Iterator<SeriesDTO> cloneFromDefaultsSeriesIter = cloneFromDefaults.series.iterator();
|
||||
while (originalSeriesIter.hasNext() && cloneFromDefaultsSeriesIter.hasNext()) {
|
||||
SeriesDTO originalSeries = originalSeriesIter.next();
|
||||
SeriesDTO cloneFromDefaultsSeries = cloneFromDefaultsSeriesIter.next();
|
||||
cloneFromDefaultsSeries.setRaceColumns(originalSeries.getRaceColumns());
|
||||
}
|
||||
regattaConfigurationsToCreate.add(cloneFromDefaults);
|
||||
}
|
||||
sailingService.createRegattaStructure(regattaConfigurationsToCreate, newEvent, new AsyncCallback<Void>() {
|
||||
|
||||
+1
-2
@@ -1,6 +1,5 @@
|
||||
package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import java.net.MalformedURLException;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
@@ -546,7 +545,7 @@ public interface SailingService extends RemoteService {
|
||||
*/
|
||||
Iterable<RegattaDTO> getRegattas(String manage2SailJsonUrl);
|
||||
|
||||
void createRegattaStructure(Iterable<RegattaDTO> regattas, EventDTO newEvent) throws MalformedURLException;
|
||||
void createRegattaStructure(Iterable<RegattaDTO> regattas, EventDTO newEvent) throws Exception;
|
||||
|
||||
Integer getStructureImportOperationProgress();
|
||||
}
|
||||
+8
-2
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@@ -39,7 +40,9 @@ public class RegattaDTO extends NamedDTO {
|
||||
}
|
||||
|
||||
/**
|
||||
* A clone / copy constructor, copying all field values, flat, from <code>other</code> to the new object
|
||||
* A clone / copy constructor, copying all field values, flat, from <code>other</code> to the new object, except for the
|
||||
* {@link #series} list which is creates as a new list with all its elements cloned using the {@link SeriesDTO#SeriesDTO(SeriesDTO)}
|
||||
* copy constructor.
|
||||
*/
|
||||
public RegattaDTO(RegattaDTO other) {
|
||||
super(other.getName());
|
||||
@@ -47,7 +50,10 @@ public class RegattaDTO extends NamedDTO {
|
||||
this.startDate = other.startDate;
|
||||
this.endDate = other.endDate;
|
||||
this.races = other.races;
|
||||
this.series = other.series;
|
||||
this.series = new ArrayList<>();
|
||||
for (SeriesDTO otherSeries : other.series) {
|
||||
this.series.add(new SeriesDTO(otherSeries)); // clone the series; clients may replace / alter their fields
|
||||
}
|
||||
this.scoringScheme = other.scoringScheme;
|
||||
this.defaultCourseAreaUuid = other.defaultCourseAreaUuid;
|
||||
this.defaultCourseAreaName = other.defaultCourseAreaName;
|
||||
|
||||
+13
-1
@@ -1,5 +1,6 @@
|
||||
package com.sap.sailing.gwt.ui.shared;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
@@ -31,7 +32,18 @@ public class SeriesDTO extends NamedDTO {
|
||||
this.firstColumnIsNonDiscardableCarryForward = firstColumnIsNonDiscardableCarryForward;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Copy/clone constructor; the {@link #raceColumns} collection is created as a copy and not just assigned by reference.
|
||||
* Therefore, altering the elements in the {@link #raceColumns} collection of the new object does not alter the {@link #raceColumns}
|
||||
* collection in <code>otherSeries</code>.
|
||||
*/
|
||||
public SeriesDTO(SeriesDTO otherSeries) {
|
||||
this(otherSeries.getName(), otherSeries.getFleets(),
|
||||
otherSeries.getRaceColumns() == null ? null : new ArrayList<RaceColumnDTO>(otherSeries.getRaceColumns()),
|
||||
otherSeries.isMedal(), otherSeries.getDiscardThresholds(), otherSeries.isStartsWithZeroScore(),
|
||||
otherSeries.isFirstColumnIsNonDiscardableCarryForward(), otherSeries.hasSplitFleetContiguousScoring());
|
||||
}
|
||||
|
||||
public boolean hasSplitFleetContiguousScoring() {
|
||||
return hasSplitFleetContiguousScoring;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user