mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-09-23 22:19:13 +00:00
Merge remote-tracking branch 'origin/master' into simulator_dev
This commit is contained in:
+4
@@ -185,6 +185,10 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
|
||||
public List<RaceColumnDTO> getRaceList() {
|
||||
return races;
|
||||
}
|
||||
|
||||
public void setRaceList(List<RaceColumnDTO> raceList) {
|
||||
this.races = raceList;
|
||||
}
|
||||
|
||||
public boolean raceListContains(String raceColumnName) {
|
||||
return getRaceColumnByName(raceColumnName) != null;
|
||||
|
||||
+33
-1
@@ -67,6 +67,14 @@ public class IncrementalLeaderboardDTO extends LeaderboardDTO implements Increme
|
||||
|
||||
private Set<String> raceColumnNamesForWhichCompetitorOrderingPerRaceUnchanged;
|
||||
|
||||
/**
|
||||
* For each index in this object's {@link #getRaceList()}, either has <code>-1</code> meaning that the element at the respective index
|
||||
* is properly set because it has changed compared to the previous version, or it has a non-negative index pointing to the previous
|
||||
* leaderboard's {@link #getRaceList()} result which has an unchanged {@link RaceColumnDTO} at that index which is to be
|
||||
* set in this object's {@link #getRaceList()} during {@link #applyThisToPreviousVersionByUpdatingThis(LeaderboardDTO) expansion}.
|
||||
*/
|
||||
private int[] indexOfUnchangedRaceColumnDTOsInPrevious;
|
||||
|
||||
private transient Cloner cloner;
|
||||
|
||||
/**
|
||||
@@ -363,7 +371,13 @@ public class IncrementalLeaderboardDTO extends LeaderboardDTO implements Increme
|
||||
}
|
||||
competitorDisplayNames = expandedCompetitorDisplayNames;
|
||||
}
|
||||
// TODO ensure that the races collection has all the necessary RaceColumnDTO objects before looking them up by name
|
||||
if (indexOfUnchangedRaceColumnDTOsInPrevious != null) {
|
||||
for (int i=0; i<indexOfUnchangedRaceColumnDTOsInPrevious.length; i++) {
|
||||
if (indexOfUnchangedRaceColumnDTOsInPrevious[i] != -1) {
|
||||
getRaceList().set(i, previousVersion.getRaceList().get(indexOfUnchangedRaceColumnDTOsInPrevious[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<String> columnNamesForWhichToExpandCompetitorOrderingPerRace = new HashSet<String>(getCompetitorOrderingPerRaceColumnName().keySet());
|
||||
for (String raceColumnNameForWhichCompetitorOrderingPerRaceUnchanged : raceColumnNamesForWhichCompetitorOrderingPerRaceUnchanged) {
|
||||
// be on the safe side regarding the equals/hashCode implementation of RaceColumnDTO and look it up by name for old and new version
|
||||
@@ -605,6 +619,24 @@ public class IncrementalLeaderboardDTO extends LeaderboardDTO implements Increme
|
||||
if (legDetailsUnchanged != null) {
|
||||
legDetailsUnchanged.compact(); // compacts even those columns where the *last* entry was one with a null leg index
|
||||
}
|
||||
if (getRaceList() != null) {
|
||||
List<RaceColumnDTO> newRaceList = new ArrayList<RaceColumnDTO>(getRaceList().size());
|
||||
indexOfUnchangedRaceColumnDTOsInPrevious = new int[getRaceList().size()];
|
||||
boolean changed = false;
|
||||
for (int raceIndex=0; raceIndex<getRaceList().size(); raceIndex++) {
|
||||
int previousIndex = previousVersion.getRaceList().indexOf(getRaceList().get(raceIndex));
|
||||
indexOfUnchangedRaceColumnDTOsInPrevious[raceIndex] = previousIndex;
|
||||
if (previousIndex != -1) {
|
||||
newRaceList.add(null);
|
||||
changed = true;
|
||||
} else {
|
||||
newRaceList.add(getRaceList().get(raceIndex));
|
||||
}
|
||||
}
|
||||
if (changed) {
|
||||
setRaceList(newRaceList);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
+45
-4
@@ -3,6 +3,7 @@ package com.sap.sailing.domain.common.test;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNotSame;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -10,6 +11,7 @@ import static org.junit.Assert.assertTrue;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -18,16 +20,19 @@ import java.util.Map;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.base.impl.MillisecondsTimePoint;
|
||||
import com.sap.sailing.domain.common.Cloner;
|
||||
import com.sap.sailing.domain.common.dto.BoatClassDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTOImpl;
|
||||
import com.sap.sailing.domain.common.dto.FleetDTO;
|
||||
import com.sap.sailing.domain.common.dto.IncrementalLeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardEntryDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardRowDTO;
|
||||
import com.sap.sailing.domain.common.dto.LegEntryDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceDTO;
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
import com.sap.sailing.domain.test.StoredTrackBasedTest;
|
||||
import com.sap.sailing.util.ClonerImpl;
|
||||
@@ -88,6 +93,7 @@ public class LeaderboardDTODiffingTest {
|
||||
@Test
|
||||
public void testMajorStripping() {
|
||||
newVersion.rows = new HashMap<CompetitorDTO, LeaderboardRowDTO>(newVersion.rows);
|
||||
List<RaceColumnDTO> raceListBeforeStripping = new ArrayList<RaceColumnDTO>(newVersion.getRaceList());
|
||||
CompetitorDTO wolfgang = getPreviousCompetitorByName("HUNGER +JESS");
|
||||
assertNotNull(wolfgang);
|
||||
LeaderboardRowDTO wolfgangsRow = new LeaderboardRowDTO();
|
||||
@@ -101,8 +107,13 @@ public class LeaderboardDTODiffingTest {
|
||||
assertEquals(1, newVersion.rows.size()); // only wolfgang's row should show
|
||||
assertEquals(wolfgang, newVersion.rows.keySet().iterator().next().getCompetitorFromPrevious(previousVersion));
|
||||
assertTrue(newVersion.rows.values().iterator().next().fieldsByRaceColumnName.isEmpty());
|
||||
for (RaceColumnDTO nullRaceColumn : newVersion.getRaceList()) {
|
||||
assertNull(nullRaceColumn); // there were no changes to the columns; expect all of them to have been eliminiated
|
||||
}
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(rowsBeforeStripping, applied.rows);
|
||||
assertNotSame(raceListBeforeStripping, applied.getRaceList());
|
||||
assertEquals(raceListBeforeStripping, applied.getRaceList());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -247,10 +258,8 @@ public class LeaderboardDTODiffingTest {
|
||||
List<CompetitorDTO> newOrderBeforeStripping = new ArrayList<CompetitorDTO>(newOrdering);
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
for (RaceColumnDTO raceColumn : newVersion.getRaceList()) {
|
||||
if (!raceColumn.getName().equals("R9")) {
|
||||
assertNull(newVersion.getCompetitorsFromBestToWorst(raceColumn));
|
||||
}
|
||||
for (int i=1; i<9; i++) {
|
||||
assertNull(newVersion.getCompetitorsFromBestToWorst("R"+i));
|
||||
}
|
||||
assertEquals(newVersion.getCompetitorsFromBestToWorst(r9).size()-1, newVersion.getCompetitorsFromBestToWorst(r9).indexOf(somebodyNew));
|
||||
for (CompetitorDTO compactSuppressedCompetitor : newVersion.getCompetitorsFromBestToWorst(r9)) {
|
||||
@@ -269,4 +278,36 @@ public class LeaderboardDTODiffingTest {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialRaceColumnDTOCompaction() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
|
||||
// create a modified R9 RaceDTO clone in newVersion to make sure that even changing a property in the RaceDTO will keep the RaceColumnDTO from being omitted
|
||||
RaceColumnDTO r9 = newVersion.getRaceColumnByName("R9");
|
||||
RaceColumnDTO clonedR9 = new RaceColumnDTO(r9.isValidInTotalScore());
|
||||
cloner.clone(r9, clonedR9);
|
||||
// also clone the racesPerFleet map, or else we'd be modifying the previous version's one too
|
||||
final Field racesPerFleetField = clonedR9.getClass().getDeclaredField("racesPerFleet");
|
||||
racesPerFleetField.setAccessible(true);
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<FleetDTO, RaceDTO> m = (Map<FleetDTO, RaceDTO>) racesPerFleetField.get(clonedR9);
|
||||
racesPerFleetField.set(clonedR9, new HashMap<FleetDTO, RaceDTO>(m));
|
||||
final FleetDTO defaultFleet = r9.getFleets().iterator().next();
|
||||
RaceDTO r9Race = r9.getRace(defaultFleet);
|
||||
RaceDTO clonedR9Race = new RaceDTO();
|
||||
cloner.clone(r9Race, clonedR9Race);
|
||||
clonedR9.setRace(defaultFleet, clonedR9Race);
|
||||
clonedR9Race.endOfRace = new MillisecondsTimePoint(r9Race.endOfRace).plus(1234).asDate();
|
||||
List<RaceColumnDTO> clonedRaceList = new ArrayList<RaceColumnDTO>(newVersion.getRaceList());
|
||||
clonedRaceList.set(clonedRaceList.indexOf(r9), clonedR9);
|
||||
newVersion.setRaceList(clonedRaceList);
|
||||
List<RaceColumnDTO> raceListBeforeStripping = new ArrayList<RaceColumnDTO>(clonedRaceList);
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
for (int i=0; i<8; i++) {
|
||||
assertNull(newVersion.getRaceList().get(i));
|
||||
}
|
||||
assertNotNull(newVersion.getRaceList().get(8));
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(raceListBeforeStripping, applied.getRaceList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
entryPointModules=
|
||||
filesCopiedToWebInfLib=g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BLIC "-//Google Inc.//DTD Google Web Toolkit 2.4.0//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.4.0/distro-source/core/src/gwt-module.dtd">
|
||||
<module>
|
||||
<source path='util'/>
|
||||
</module>
|
||||
@@ -151,6 +151,15 @@ To ensure availability and to be able to separate servers holding historical dat
|
||||
<td>N/A</td>
|
||||
<td>14890</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>RACECOMMITTEE_APP</td>
|
||||
<td>7777</td>
|
||||
<td>10201</td>
|
||||
<td>/opt/mongodb/data/mongodb-live</td>
|
||||
<td>sapsailinganalytics-racecommitteeapp</td>
|
||||
<td>2010</td>
|
||||
<td>14777</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
### Apache
|
||||
|
||||
Reference in New Issue
Block a user