mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-08 21:30:57 +00:00
Merge branch 'master' into racecommittee_app
This commit is contained in:
commit
5456d95192
185 files changed
+4086
-1373
No files matched your search
@@ -342,6 +342,12 @@ if [[ "$@" == "install" ]] || [[ "$@" == "all" ]]; then
|
||||
rm -rf $ACDIR/org.eclipse.*
|
||||
rm -rf $ACDIR/configuration/org.eclipse.*
|
||||
|
||||
if [ ! -f "$ACDIR/env.sh" ]; then
|
||||
cp -v $PROJECT_HOME/java/target/env.sh $ACDIR/
|
||||
cp -v $PROJECT_HOME/java/target/start $ACDIR/
|
||||
cp -v $PROJECT_HOME/java/target/stop $ACDIR/
|
||||
fi
|
||||
|
||||
if [[ $HAS_OVERWRITTEN_TARGET -eq 0 ]] && [ ! -f $ACDIR/no-overwrite ]; then
|
||||
cp -v $p2PluginRepository/configuration/config.ini configuration/
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ Like businesses, sailors need the latest information to make strategic decisions
|
||||
* [[General Project Information|wiki/general-information]]
|
||||
* Production Environment
|
||||
* [[PIRONET (Hosting Provider, Emergency Procedures)|wiki/prionet-related-information]]
|
||||
* [[Amazon EC2|wiki/amazon-ec2]]
|
||||
* [[Production Environment|wiki/production-environment]]
|
||||
* [[TracTrac Lifecycle for Event Managers|wiki/tractrac-lifecycle]]
|
||||
* Information for Developers
|
||||
|
||||
@@ -9,6 +9,7 @@ Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.sap.sailing.domain.common,
|
||||
com.sap.sailing.domain.common.filter,
|
||||
com.sap.sailing.domain.common.impl,
|
||||
com.sap.sailing.domain.common.media,
|
||||
com.sap.sailing.domain.common.quadtree,
|
||||
com.sap.sailing.domain.common.quadtree.impl;x-friends:="com.sap.sailing.domain.test",
|
||||
com.sap.sailing.domain.common.racelog,
|
||||
|
||||
+6
-1
@@ -8,7 +8,7 @@ public abstract class AbstractSpeedImpl implements Speed {
|
||||
|
||||
@Override
|
||||
public double getBeaufort() {
|
||||
return Math.exp(Math.log(getKnots()*1.852/3.6 / 0.8360)*2/3);
|
||||
return Math.exp(Math.log(getMetersPerSecond()/0.8360) * 2./3.);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,4 +48,9 @@ public abstract class AbstractSpeedImpl implements Speed {
|
||||
}
|
||||
return getMetersPerSecond() == ((Speed) object).getMetersPerSecond();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getKnots() {
|
||||
return getKilometersPerHour() * 1000. / Mile.METERS_PER_NAUTICAL_MILE;
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
package com.sap.sailing.domain.common;
|
||||
|
||||
public interface Cloner {
|
||||
void clone(Object from, Object to);
|
||||
}
|
||||
+6
-6
@@ -36,11 +36,11 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
|
||||
public AbstractLeaderboardDTO() {
|
||||
races = new ArrayList<RaceColumnDTO>();
|
||||
}
|
||||
|
||||
|
||||
public Set<BoatClassDTO> getBoatClasses() {
|
||||
Set<BoatClassDTO> result = new HashSet<BoatClassDTO>();
|
||||
for (CompetitorDTO competitor : rows.keySet()) {
|
||||
result.add(competitor.boatClass);
|
||||
result.add(competitor.getBoatClass());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -51,7 +51,7 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
|
||||
|
||||
public String getDisplayName(CompetitorDTO competitor) {
|
||||
if (competitorDisplayNames == null || competitorDisplayNames.get(competitor) == null) {
|
||||
return competitor.name;
|
||||
return competitor.getName();
|
||||
} else {
|
||||
return competitorDisplayNames.get(competitor);
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
|
||||
RaceColumnDTO result = getRaceColumnByName(raceColumnName);
|
||||
if (result == null) {
|
||||
result = new RaceColumnDTO(/* isValidInTotalScore */ true);
|
||||
result.name = raceColumnName;
|
||||
result.setName(raceColumnName);
|
||||
races.add(result);
|
||||
}
|
||||
return result;
|
||||
@@ -151,7 +151,7 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
|
||||
raceColumnDTO.setExplicitFactor(explicitFactor);
|
||||
boolean contains = false;
|
||||
for (FleetDTO fleet : raceColumnDTO.getFleets()) {
|
||||
if (fleet.name.equals(fleetDTO.name)) {
|
||||
if (fleet.getName().equals(fleetDTO.getName())) {
|
||||
contains = true;
|
||||
break;
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public abstract class AbstractLeaderboardDTO implements Serializable {
|
||||
|
||||
public RaceColumnDTO createEmptyRaceColumn(String raceColumnName, boolean medalRace, boolean isValidInTotalScore) {
|
||||
RaceColumnDTO raceColumn = new RaceColumnDTO(isValidInTotalScore);
|
||||
raceColumn.name = raceColumnName;
|
||||
raceColumn.setName(raceColumnName);
|
||||
raceColumn.setMedalRace(medalRace);
|
||||
races.add(raceColumn);
|
||||
return raceColumn;
|
||||
|
||||
+18
-43
@@ -2,51 +2,26 @@ package com.sap.sailing.domain.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CompetitorDTO extends NamedDTO implements Serializable {
|
||||
private static final long serialVersionUID = -4997852354821083154L;
|
||||
public String twoLetterIsoCountryCode;
|
||||
public String threeLetterIocCountryCode;
|
||||
public String countryName;
|
||||
public String sailID;
|
||||
public String idAsString;
|
||||
public BoatClassDTO boatClass;
|
||||
public interface CompetitorDTO extends Serializable {
|
||||
|
||||
CompetitorDTO() {}
|
||||
String getTwoLetterIsoCountryCode();
|
||||
|
||||
String getThreeLetterIocCountryCode();
|
||||
|
||||
String getCountryName();
|
||||
|
||||
String getSailID();
|
||||
|
||||
String getIdAsString();
|
||||
|
||||
BoatClassDTO getBoatClass();
|
||||
|
||||
public CompetitorDTO(String name, String twoLetterIsoCountryCode, String threeLetterIocCountryCode,
|
||||
String countryName, String sailID, String idAsString, BoatClassDTO boatClass) {
|
||||
super(name);
|
||||
this.twoLetterIsoCountryCode = twoLetterIsoCountryCode;
|
||||
this.threeLetterIocCountryCode = threeLetterIocCountryCode;
|
||||
this.countryName = countryName;
|
||||
this.sailID = sailID;
|
||||
this.idAsString = idAsString;
|
||||
this.boatClass = boatClass;
|
||||
}
|
||||
String getName();
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * idAsString.hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CompetitorDTO other = (CompetitorDTO) obj;
|
||||
if (idAsString == null) {
|
||||
if (other.idAsString != null)
|
||||
return false;
|
||||
} else if (!idAsString.equals(other.idAsString))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* A regular instance will simply return this object. A compacted version may compute the result by looking it up
|
||||
* from the previous version of the enclosing leaderboard.
|
||||
*/
|
||||
CompetitorDTO getCompetitorFromPrevious(LeaderboardDTO previousVersion);
|
||||
|
||||
}
|
||||
Executable
+87
@@ -0,0 +1,87 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class CompetitorDTOImpl extends NamedDTO implements CompetitorDTO, Serializable {
|
||||
private static final long serialVersionUID = -4997852354821083154L;
|
||||
private String twoLetterIsoCountryCode;
|
||||
private String threeLetterIocCountryCode;
|
||||
private String countryName;
|
||||
private String sailID;
|
||||
private String idAsString;
|
||||
private BoatClassDTO boatClass;
|
||||
|
||||
CompetitorDTOImpl() {}
|
||||
|
||||
public CompetitorDTOImpl(String name, String twoLetterIsoCountryCode, String threeLetterIocCountryCode,
|
||||
String countryName, String sailID, String idAsString, BoatClassDTO boatClass) {
|
||||
super(name);
|
||||
this.twoLetterIsoCountryCode = twoLetterIsoCountryCode;
|
||||
this.threeLetterIocCountryCode = threeLetterIocCountryCode;
|
||||
this.countryName = countryName;
|
||||
this.sailID = sailID;
|
||||
this.idAsString = idAsString;
|
||||
this.boatClass = boatClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * getIdAsString().hashCode();
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CompetitorDTOImpl other = (CompetitorDTOImpl) obj;
|
||||
if (getIdAsString() == null) {
|
||||
if (other.getIdAsString() != null)
|
||||
return false;
|
||||
} else if (!getIdAsString().equals(other.getIdAsString()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTwoLetterIsoCountryCode() {
|
||||
return twoLetterIsoCountryCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getThreeLetterIocCountryCode() {
|
||||
return threeLetterIocCountryCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountryName() {
|
||||
return countryName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSailID() {
|
||||
return sailID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAsString() {
|
||||
return idAsString;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatClassDTO getBoatClass() {
|
||||
return boatClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorDTO getCompetitorFromPrevious(LeaderboardDTO previousVersion) {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
||||
+5
-19
@@ -7,14 +7,10 @@ public class FleetDTO extends NamedDTO {
|
||||
private Color color;
|
||||
private int orderNo;
|
||||
|
||||
/** the name of the series the fleet belongs to */
|
||||
private String seriesName;
|
||||
|
||||
public FleetDTO() {}
|
||||
|
||||
public FleetDTO(String fleetName, String seriesName, int orderNo, Color color) {
|
||||
public FleetDTO(String fleetName, int orderNo, Color color) {
|
||||
super(fleetName);
|
||||
this.seriesName = seriesName;
|
||||
this.orderNo = orderNo;
|
||||
this.color = color;
|
||||
}
|
||||
@@ -35,17 +31,12 @@ public class FleetDTO extends NamedDTO {
|
||||
this.orderNo = orderNo;
|
||||
}
|
||||
|
||||
public String getSeriesName() {
|
||||
return seriesName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + orderNo;
|
||||
result = prime * result + ((seriesName == null) ? 0 : seriesName.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -58,18 +49,13 @@ public class FleetDTO extends NamedDTO {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
FleetDTO other = (FleetDTO) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
if (getName() == null) {
|
||||
if (other.getName() != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
} else if (!getName().equals(other.getName()))
|
||||
return false;
|
||||
if (orderNo != other.orderNo)
|
||||
return false;
|
||||
if (seriesName == null) {
|
||||
if (other.seriesName != null)
|
||||
return false;
|
||||
} else if (!seriesName.equals(other.seriesName))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Executable
+18
@@ -0,0 +1,18 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
public class FullLeaderboardDTO implements IncrementalOrFullLeaderboardDTO {
|
||||
private static final long serialVersionUID = 8958803649569036100L;
|
||||
private LeaderboardDTO leaderboardDTO;
|
||||
|
||||
FullLeaderboardDTO() {}
|
||||
|
||||
public FullLeaderboardDTO(LeaderboardDTO leaderboardDTO) {
|
||||
this.leaderboardDTO = leaderboardDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeaderboardDTO getLeaderboardDTO(LeaderboardDTO previousVersion) {
|
||||
return leaderboardDTO;
|
||||
}
|
||||
|
||||
}
|
||||
+646
@@ -0,0 +1,646 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
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.Set;
|
||||
|
||||
import com.sap.sailing.domain.common.Cloner;
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
|
||||
/**
|
||||
* Reduces the transmission size of a {@link LeaderboardDTO} by comparing this object to a previous version of
|
||||
* this object. For memory-consuming elements that equal the corresponding elements in the previous version,
|
||||
* only a marker about the equality is remembered, and the space-consuming structure is replaced by a <code>null</code>
|
||||
* value. On the receiving end where the previous version is also present, those <code>null</code> values can then be
|
||||
* replaced by the previous value.<p>
|
||||
*
|
||||
* The "compression" is performed by the {@link #strip(LeaderboardDTO)} method on the sending end, and the
|
||||
* "de-compression" happens in the {@link #applyThisToPreviousVersionByUpdatingThis(LeaderboardDTO)} method
|
||||
* on the receiving end.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class IncrementalLeaderboardDTO extends LeaderboardDTO implements IncrementalOrFullLeaderboardDTO {
|
||||
private static final long serialVersionUID = -7011986430671280594L;
|
||||
private String isDiffToLeaderboardDTOWithId;
|
||||
|
||||
private String updatedFromPreviousVersionWithId;
|
||||
|
||||
private boolean commentUnchanged;
|
||||
|
||||
/**
|
||||
* If <code>null</code>, {@link #competitors} is filled and must not be touched; otherwise, the size of the array tells the new size
|
||||
* of {@link #competitors}, and for each index it either tells the index of the {@link CompetitorDTO} object to use in the previous
|
||||
* leaderboard's {@link #competitors} list, or holds -1, meaning that the next {@link CompetitorDTO} object is to be used from
|
||||
* {@link #addedCompetitors} which only needs to hold a valid collection if at least one new competitor exists.
|
||||
*/
|
||||
private int[] competitorIndexesInPreviousCompetitorsList;
|
||||
|
||||
/**
|
||||
* The "uncompacted" original competitors that were added. There is no need to try to compact these because they haven't existed
|
||||
* in the previous leaderboard and therefore need to be transmitted in their entirety.
|
||||
*/
|
||||
private List<CompetitorDTO> addedCompetitors;
|
||||
|
||||
private boolean suppressedCompetitorsUnchanged;
|
||||
private boolean competitorDisplayNamesUnchanged;
|
||||
private boolean regattaNameUnchanged;
|
||||
private boolean displayNameUnchanged;
|
||||
private boolean defaultCourseAreaIdAsStringUnchanged;
|
||||
private boolean defaultCourseAreaNameUnchanged;
|
||||
|
||||
/**
|
||||
* If a {@link LeaderboardEntryDTO} in {@link LeaderboardRowDTO#fieldsByRaceColumnName} is unchanged, this field
|
||||
* holds a valid object which describes for which competitors in which race columns their leaderboard entry is
|
||||
* unchanged as compared to the previous leaderboard. As key, the race column name is used. This field can be
|
||||
* <code>null</code>, meaning that there are no unchanged leaderboard entries.
|
||||
*/
|
||||
private UnchangedWithCompetitorsInBitSet<String> unchangedLeaderboardEntries;
|
||||
|
||||
private Set<String> raceColumnNamesForWhichCompetitorOrderingPerRaceUnchanged;
|
||||
|
||||
private transient Cloner cloner;
|
||||
|
||||
/**
|
||||
* If a {@link LegEntryDTO} is unchanged in an otherwise modified {@link LeaderboardEntryDTO}, this is recorded in
|
||||
* this field. The key is the pair of race column name and the leg number, both starting with zero. If <code>null</code>
|
||||
* is used for the leg number, this means that for that competitor in that race, all leg details are unchanged as compared
|
||||
* to the previous version.
|
||||
* <p>
|
||||
*
|
||||
* This field can be <code>null</code>, meaning that there are no unchanged leg details.
|
||||
*/
|
||||
private UnchangedLegDetails legDetailsUnchanged;
|
||||
|
||||
/**
|
||||
* The single key is <code>null</code> if the field is not <code>null</code>. The value identifies the competitors
|
||||
* for which the entire row is unchanged in {@link #rows}.
|
||||
*/
|
||||
private UnchangedWithCompetitorsInBitSet<Void> rowsUnchanged;
|
||||
|
||||
static class UnchangedWithCompetitorsInBitSet<K> implements Serializable {
|
||||
private static final long serialVersionUID = 504599408604780499L;
|
||||
private transient int totalNumberOfCompetitorsInNewLeaderboard;
|
||||
private transient LeaderboardDTO previousLeaderboard;
|
||||
|
||||
/**
|
||||
* Values are bit sets where the bits encode competitors by their position in {@link #previousLeaderboard}'s
|
||||
* {@link LeaderboardDTO#competitors} list; if a competitor has its bit set, this means that its value corresponding
|
||||
* to the key of type <code>K</code> used as key to this map is unchanged between previous and current leaderboard
|
||||
* version. If the value is unchanged for <em>all</em> competitors for one key, <code>null</code> is used as the value
|
||||
* in this map instead of the bit set.
|
||||
*/
|
||||
private Map<K, long[]> unchanged;
|
||||
|
||||
UnchangedWithCompetitorsInBitSet() {} // for serialization/deserialization
|
||||
|
||||
public UnchangedWithCompetitorsInBitSet(LeaderboardDTO previousLeaderboard, int totalNumberOfCompetitorsInNewLeaderboard) {
|
||||
this.previousLeaderboard = previousLeaderboard;
|
||||
this.totalNumberOfCompetitorsInNewLeaderboard = totalNumberOfCompetitorsInNewLeaderboard;
|
||||
unchanged = new HashMap<K, long[]>();
|
||||
}
|
||||
|
||||
/**
|
||||
* ORs two bit sets into a new bit set; the bit sets may have different or zero lengths and can even be <code>null</code>
|
||||
*/
|
||||
protected long[] or(long[] a, long[] b) {
|
||||
final int maxLength = Math.max(a==null?0:a.length, b==null?0:b.length);
|
||||
long[] result = new long[maxLength];
|
||||
for (int i=0; i<maxLength; i++) {
|
||||
if (a != null && a.length > i) {
|
||||
result[i] |= a[i];
|
||||
}
|
||||
if (b != null && b.length > i) {
|
||||
result[i] |= b[i];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
protected int getNumberOfSetBits(K key) {
|
||||
return getNumberOfBitsSet(getUnchangedBitset(key));
|
||||
}
|
||||
|
||||
protected int getNumberOfBitsSet(long[] bitset) {
|
||||
int result = 0;
|
||||
for (int i=0; i<bitset.length; i++) {
|
||||
for (int j=0; j<Long.SIZE; j++) {
|
||||
if ((bitset[i] & 1l << j) != 0) {
|
||||
result++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a bit set that is large enough to hold the bit for the index of <code>competitor</code> in the previous leaderboard's competitors
|
||||
* list and sets the bit for that competitor.
|
||||
*/
|
||||
private long[] createBitSet(CompetitorDTO competitor) {
|
||||
final int indexOfCompetitor = previousLeaderboard.competitors.indexOf(competitor);
|
||||
long[] result = new long[1+indexOfCompetitor/Long.SIZE];
|
||||
result[indexOfCompetitor/Long.SIZE] = 1l << (indexOfCompetitor%Long.SIZE);
|
||||
return result;
|
||||
}
|
||||
|
||||
private int getIndexOfCompetitor(CompetitorDTO competitor) {
|
||||
return previousLeaderboard.competitors.indexOf(competitor);
|
||||
}
|
||||
|
||||
protected int getTotalNumberOfCompetitorsInNewLeaderboard() {
|
||||
return totalNumberOfCompetitorsInNewLeaderboard;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param previousVersion needed because after serialization/deserialization, the transient {@link #previousLeaderboard} will be <code>null</code>
|
||||
*/
|
||||
public Set<Pair<CompetitorDTO, K>> getAllUnchangedCompetitorsAndKeys(LeaderboardDTO previousVersion) {
|
||||
Set<Pair<CompetitorDTO, K>> result = new HashSet<Util.Pair<CompetitorDTO,K>>();
|
||||
for (Map.Entry<K, long[]> raceColumnNameAndBitSet : unchanged.entrySet()) {
|
||||
final long[] bitset = raceColumnNameAndBitSet.getValue();
|
||||
if (bitset == null) {
|
||||
// this means that all entries for the column are unchanged for all competitors
|
||||
for (CompetitorDTO competitor : previousVersion.competitors) {
|
||||
result.add(new Pair<CompetitorDTO, K>(competitor, raceColumnNameAndBitSet.getKey()));
|
||||
}
|
||||
} else {
|
||||
int competitorNumber = 0;
|
||||
for (int arrayIndex = 0; arrayIndex < bitset.length; arrayIndex++) {
|
||||
long bitValue = 1;
|
||||
for (int bit=0; bit<Long.SIZE; bit++) {
|
||||
if ((bitset[arrayIndex] & bitValue) != 0) {
|
||||
result.add(new Pair<CompetitorDTO, K>(previousVersion.competitors.get(competitorNumber), raceColumnNameAndBitSet.getKey()));
|
||||
}
|
||||
bitValue <<= 1;
|
||||
competitorNumber++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Declares that the value for the given <code>competitor</code> for key <code>key</code> is unchanged when
|
||||
* compared to the previous version.
|
||||
* <p>
|
||||
*
|
||||
* If this means that the values are unchanged for <em>all</em> competitors for that key, the internal
|
||||
* representation is compacted for less bandwidth-consuming serialization.
|
||||
*/
|
||||
public void unchanged(CompetitorDTO competitor, K key) {
|
||||
long[] bitset = getUnchangedBitset(key);
|
||||
if (bitset == null) {
|
||||
bitset = createBitSet(competitor);
|
||||
unchanged.put(key, bitset);
|
||||
} else {
|
||||
final int indexOfCompetitor = getIndexOfCompetitor(competitor);
|
||||
if (bitset.length <= indexOfCompetitor/Long.SIZE) {
|
||||
// bitset array is too short; extend
|
||||
long[] newBitset = new long[1+indexOfCompetitor/Long.SIZE];
|
||||
System.arraycopy(bitset, 0, newBitset, 0, bitset.length);
|
||||
bitset = newBitset;
|
||||
unchanged.put(key, bitset);
|
||||
}
|
||||
bitset[indexOfCompetitor/Long.SIZE] |= 1l << (indexOfCompetitor%Long.SIZE);
|
||||
}
|
||||
tryToCompact(key);
|
||||
}
|
||||
|
||||
protected void tryToCompact(K key) {
|
||||
if (getNumberOfSetBits(key) >= getTotalNumberOfCompetitorsInNewLeaderboard()) {
|
||||
// unchanged for all; set bitset to null in map, representing this fact
|
||||
unchanged.put(key, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected long[] getUnchangedBitset(K key) {
|
||||
return unchanged.get(key);
|
||||
}
|
||||
|
||||
protected Set<K> getAllUnchangedKeys() {
|
||||
return Collections.unmodifiableSet(unchanged.keySet());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A specialized, bit set-based structure for marking leg details that haven't changed. The key is a composite of
|
||||
* the race column name and the zero-based leg index. If <code>null</code> is used for the leg index in a call to
|
||||
* {@link #unchanged(CompetitorDTO, Object)}, this means that all leg details in that race were unchanged for the
|
||||
* competitor, e.g., because they were <code>null</code> both in the old and new version.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
static class UnchangedLegDetails extends UnchangedWithCompetitorsInBitSet<Pair<String, Integer>> {
|
||||
private static final long serialVersionUID = 8726138955651801210L;
|
||||
|
||||
UnchangedLegDetails() {} // for (de)serialization
|
||||
|
||||
public UnchangedLegDetails(LeaderboardDTO previousLeaderboard, int totalNumberOfCompetitorsInNewLeaderboard) {
|
||||
super(previousLeaderboard, totalNumberOfCompetitorsInNewLeaderboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* For all keys with non-<code>null</code> leg index, combine the competitor (bit)set with that for the
|
||||
* key with the same respective race column name and <code>null</code> as the leg index. The latter competitors
|
||||
* are those for which the leg details are both <code>null</code> in the old and the new version, and therefore
|
||||
* unchanged. If for any of the keys with non-<code>null</code> leg index this leads to a competitor (bit)set that
|
||||
* has at least {@link #getTotalNumberOfCompetitorsInNewLeaderboard()} entries, then this bit set can be replaced
|
||||
* by <code>null</code>, meaning the race column / leg details are unchnaged for all competitors.
|
||||
*/
|
||||
public void compact() {
|
||||
for (Pair<String, Integer> key : getAllUnchangedKeys()) {
|
||||
if (key.getB() != null) {
|
||||
tryToCompact(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* If the key's leg index is not <code>null</code>, then the bits of the entry with the leg index replaced by <code>null</code>
|
||||
* is OR-ed to the bit set found for <code>key</code>, computing the competitors for which the entry at <code>key</code> is unchanged
|
||||
* or for which all entries in the race column are unchanged.
|
||||
*/
|
||||
@Override
|
||||
protected int getNumberOfSetBits(Pair<String, Integer> key) {
|
||||
int result;
|
||||
if (key.getB() != null) {
|
||||
long[] bitset = getUnchangedBitset(key);
|
||||
long[] nullBitset = getUnchangedBitset(new Pair<String, Integer>(key.getA(), null));
|
||||
long[] orBitset = or(bitset, nullBitset);
|
||||
result = getNumberOfBitsSet(orBitset);
|
||||
} else {
|
||||
// the key asks "which competitors have their leg details unchanged for the race named key.getA() and all legs within with legDetails==null?
|
||||
result = super.getNumberOfSetBits(key);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
IncrementalLeaderboardDTO() {}
|
||||
|
||||
public IncrementalLeaderboardDTO(String id, Cloner cloner) {
|
||||
super(id);
|
||||
this.cloner = cloner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public LeaderboardDTO getLeaderboardDTO(LeaderboardDTO previousVersion) {
|
||||
if (previousVersion == null) {
|
||||
throw new IllegalArgumentException("Must provide a valid previous leaderboard version to reconstruct full LeaderboardDTO from differential leaderboard DTO");
|
||||
}
|
||||
applyThisToPreviousVersionByUpdatingThis(previousVersion);
|
||||
return this;
|
||||
}
|
||||
|
||||
private void applyThisToPreviousVersionByUpdatingThis(LeaderboardDTO previousVersion) {
|
||||
if (this.updatedFromPreviousVersionWithId != null) {
|
||||
if (!this.updatedFromPreviousVersionWithId.equals(previousVersion.getId())) {
|
||||
throw new IllegalStateException("This incremental leaderboard DTO was already applied to a different previous version. It cannot be applied multiple times.");
|
||||
} else {
|
||||
// the previous version remains unchanged; no need to make any changes, no need to throw an exception
|
||||
}
|
||||
} else {
|
||||
if (!isDiffToLeaderboardDTOWithId.equals(previousVersion.getId())) {
|
||||
throw new IllegalArgumentException("Trying to apply leaderboard DTO diff to leaderboard DTO with ID "+previousVersion.getId()+
|
||||
" although the diff was meant to be applied to a leaderboard DTO with ID "+isDiffToLeaderboardDTOWithId);
|
||||
}
|
||||
this.updatedFromPreviousVersionWithId = previousVersion.getId();
|
||||
if (this.commentUnchanged) {
|
||||
this.setComment(previousVersion.getComment());
|
||||
}
|
||||
if (this.defaultCourseAreaIdAsStringUnchanged) {
|
||||
this.defaultCourseAreaIdAsString = previousVersion.defaultCourseAreaIdAsString;
|
||||
}
|
||||
if (this.defaultCourseAreaNameUnchanged) {
|
||||
this.defaultCourseAreaName = previousVersion.defaultCourseAreaName;
|
||||
}
|
||||
if (this.displayNameUnchanged) {
|
||||
this.displayName = previousVersion.displayName;
|
||||
}
|
||||
if (this.regattaNameUnchanged) {
|
||||
this.regattaName = previousVersion.regattaName;
|
||||
}
|
||||
if (this.competitorIndexesInPreviousCompetitorsList != null) {
|
||||
this.competitors = new ArrayList<CompetitorDTO>(competitorIndexesInPreviousCompetitorsList.length);
|
||||
Iterator<CompetitorDTO> addedCompetitorsIter = null;
|
||||
for (int i=0; i<competitorIndexesInPreviousCompetitorsList.length; i++) {
|
||||
if (competitorIndexesInPreviousCompetitorsList[i] == -1) {
|
||||
if (addedCompetitorsIter==null) {
|
||||
addedCompetitorsIter = addedCompetitors.iterator();
|
||||
}
|
||||
this.competitors.add(addedCompetitorsIter.next());
|
||||
} else {
|
||||
this.competitors.add(previousVersion.competitors.get(competitorIndexesInPreviousCompetitorsList[i]));
|
||||
}
|
||||
}
|
||||
}
|
||||
List<CompetitorDTO> suppressedCompetitors = new ArrayList<CompetitorDTO>();
|
||||
if (suppressedCompetitorsUnchanged) {
|
||||
Util.addAll(previousVersion.getSuppressedCompetitors(), suppressedCompetitors);
|
||||
} else {
|
||||
for (CompetitorDTO compactSuppressedCompetitor : getSuppressedCompetitors()) {
|
||||
suppressedCompetitors.add(compactSuppressedCompetitor.getCompetitorFromPrevious(previousVersion));
|
||||
}
|
||||
}
|
||||
setSuppressedCompetitors(suppressedCompetitors);
|
||||
if (competitorDisplayNamesUnchanged) {
|
||||
competitorDisplayNames = previousVersion.competitorDisplayNames;
|
||||
} else {
|
||||
Map<CompetitorDTO, String> expandedCompetitorDisplayNames = new HashMap<CompetitorDTO, String>();
|
||||
for (Map.Entry<CompetitorDTO, String> e : competitorDisplayNames.entrySet()) {
|
||||
expandedCompetitorDisplayNames.put(e.getKey().getCompetitorFromPrevious(previousVersion), e.getValue());
|
||||
}
|
||||
competitorDisplayNames = expandedCompetitorDisplayNames;
|
||||
}
|
||||
// TODO ensure that the races collection has all the necessary RaceColumnDTO objects before looking them up by name
|
||||
Set<RaceColumnDTO> columnsForWhichToExpandCompetitorOrderingPerRace = new HashSet<RaceColumnDTO>(getCompetitorOrderingPerRace().keySet());
|
||||
for (String raceColumnNameForWhichCompetitorOrderingPerRaceUnchanged : raceColumnNamesForWhichCompetitorOrderingPerRaceUnchanged) {
|
||||
RaceColumnDTO raceColumn = getRaceColumnByName(raceColumnNameForWhichCompetitorOrderingPerRaceUnchanged);
|
||||
// be on the safe side regarding the equals/hashCode implementation of RaceColumnDTO and look it up by name for old and new version
|
||||
RaceColumnDTO previousRaceColumn = previousVersion.getRaceColumnByName(raceColumnNameForWhichCompetitorOrderingPerRaceUnchanged);
|
||||
setCompetitorsFromBestToWorst(raceColumn, previousVersion.getCompetitorsFromBestToWorst(previousRaceColumn));
|
||||
columnsForWhichToExpandCompetitorOrderingPerRace.remove(raceColumn);
|
||||
}
|
||||
// expand all other ordered competitor lists for all races where it changed
|
||||
for (RaceColumnDTO columnForWhichToExpandCompetitorOrderingPerRace : columnsForWhichToExpandCompetitorOrderingPerRace) {
|
||||
List<CompetitorDTO> competitorsFromBestToWorstForRace = getCompetitorsFromBestToWorst(columnForWhichToExpandCompetitorOrderingPerRace);
|
||||
for (int i=competitorsFromBestToWorstForRace.size()-1; i>=0; i--) {
|
||||
competitorsFromBestToWorstForRace.set(i, competitorsFromBestToWorstForRace.get(i).getCompetitorFromPrevious(previousVersion));
|
||||
}
|
||||
}
|
||||
if (rows == null) {
|
||||
rows = new HashMap<CompetitorDTO, LeaderboardRowDTO>();
|
||||
}
|
||||
// expand all keys and remove values from compact keys and re-enter with expanded keys; expand their competitor field
|
||||
for (CompetitorDTO compactCompetitor : new ArrayList<CompetitorDTO>(rows.keySet())) {
|
||||
final CompetitorDTO expandedCompetitor = compactCompetitor.getCompetitorFromPrevious(previousVersion);
|
||||
final LeaderboardRowDTO row = rows.remove(compactCompetitor);
|
||||
row.competitor = expandedCompetitor;
|
||||
rows.put(expandedCompetitor, row);
|
||||
}
|
||||
final Set<CompetitorDTO> rowsUnchangedForCompetitors = new HashSet<CompetitorDTO>();
|
||||
if (rowsUnchanged != null) {
|
||||
for (Pair<CompetitorDTO, Void> rowUnchanged : rowsUnchanged.getAllUnchangedCompetitorsAndKeys(previousVersion)) {
|
||||
rowsUnchangedForCompetitors.add(rowUnchanged.getA());
|
||||
rows.put(rowUnchanged.getA(), previousVersion.rows.get(rowUnchanged.getA()));
|
||||
}
|
||||
}
|
||||
final Set<Pair<CompetitorDTO, String>> allUnchangedLeaderboardEntriesAsCompetitorsAndColumnNames =
|
||||
unchangedLeaderboardEntries == null ? new HashSet<Util.Pair<CompetitorDTO,String>>() :
|
||||
unchangedLeaderboardEntries.getAllUnchangedCompetitorsAndKeys(previousVersion);
|
||||
if (unchangedLeaderboardEntries != null) {
|
||||
for (Pair<CompetitorDTO, String> competitorAndColumnName : allUnchangedLeaderboardEntriesAsCompetitorsAndColumnNames) {
|
||||
CompetitorDTO previousCompetitor = competitorAndColumnName.getA();
|
||||
if (!rowsUnchangedForCompetitors.contains(previousCompetitor)) { // only care if not the entire row was marked unchanged
|
||||
LeaderboardEntryDTO previousEntry = previousVersion.rows.get(previousCompetitor).fieldsByRaceColumnName.get(
|
||||
competitorAndColumnName.getB());
|
||||
rows.get(previousCompetitor).fieldsByRaceColumnName.put(competitorAndColumnName.getB(), previousEntry);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (legDetailsUnchanged != null) {
|
||||
for (Pair<CompetitorDTO, Pair<String, Integer>> competitorInPreviosAndColumnNameAndLegDetailsIndex : legDetailsUnchanged
|
||||
.getAllUnchangedCompetitorsAndKeys(previousVersion)) {
|
||||
CompetitorDTO previousCompetitor = competitorInPreviosAndColumnNameAndLegDetailsIndex.getA();
|
||||
final String raceColumnName = competitorInPreviosAndColumnNameAndLegDetailsIndex.getB().getA();
|
||||
// if it's already clear that the entire LeaderboardEntryDTO was unchanged, the entry in legDetailsUnchanged was
|
||||
// merely a hint for column compression within legDetailsUnchanged and doesn't need to be handled here
|
||||
if (!allUnchangedLeaderboardEntriesAsCompetitorsAndColumnNames
|
||||
.contains(new Pair<CompetitorDTO, String>(previousCompetitor, raceColumnName))) {
|
||||
LeaderboardEntryDTO leaderboardEntry = rows.get(previousCompetitor).fieldsByRaceColumnName.get(raceColumnName);
|
||||
final LeaderboardEntryDTO previousLeaderboardEntryDTO = previousVersion.rows.get(previousCompetitor).fieldsByRaceColumnName.get(raceColumnName);
|
||||
final List<LegEntryDTO> previousLegDetails = previousLeaderboardEntryDTO == null ? null : previousLeaderboardEntryDTO.legDetails;
|
||||
if (previousLegDetails == null) {
|
||||
// the leg index can only be null if the previous leg details are null
|
||||
leaderboardEntry.legDetails = null;
|
||||
} else {
|
||||
// here, the leg index cannot be null
|
||||
if (leaderboardEntry.legDetails == null) {
|
||||
leaderboardEntry.legDetails = new ArrayList<LegEntryDTO>();
|
||||
}
|
||||
final Integer pos = competitorInPreviosAndColumnNameAndLegDetailsIndex.getB().getB();
|
||||
ensureSize(leaderboardEntry.legDetails, pos + 1);
|
||||
leaderboardEntry.legDetails.set(pos, previousLegDetails.get(pos));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureSize(List<?> list, int size) {
|
||||
while (list.size() < size) {
|
||||
list.add(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO handle exceptions in here; log them very prominently; then continue in a fail-safe way as this is very central to leaderboard delivery
|
||||
*
|
||||
* @return for easy chaining, <code>this</code> object is returned
|
||||
*/
|
||||
public IncrementalLeaderboardDTO strip(LeaderboardDTO previousVersion) {
|
||||
isDiffToLeaderboardDTOWithId = previousVersion.getId();
|
||||
if (Util.equalsWithNull(this.getComment(), previousVersion.getComment())) {
|
||||
this.setComment(null);
|
||||
this.commentUnchanged = true;
|
||||
}
|
||||
if (Util.equalsWithNull(this.regattaName, previousVersion.regattaName)) {
|
||||
this.regattaName = null;
|
||||
this.regattaNameUnchanged = true;
|
||||
}
|
||||
if (Util.equalsWithNull(this.displayName, previousVersion.displayName)) {
|
||||
this.displayName = null;
|
||||
this.displayNameUnchanged = true;
|
||||
}
|
||||
if (Util.equalsWithNull(this.defaultCourseAreaIdAsString, previousVersion.defaultCourseAreaIdAsString)) {
|
||||
this.defaultCourseAreaIdAsString = null;
|
||||
this.defaultCourseAreaIdAsStringUnchanged = true;
|
||||
}
|
||||
if (Util.equalsWithNull(this.defaultCourseAreaName, previousVersion.defaultCourseAreaName)) {
|
||||
this.defaultCourseAreaName = null;
|
||||
this.defaultCourseAreaNameUnchanged = true;
|
||||
}
|
||||
competitorIndexesInPreviousCompetitorsList = new int[competitors.size()];
|
||||
// for this stripping run, remembers the mapping of real CompetitorDTO objects to the compact form that only holds an int as reference to the
|
||||
// previous version's competitors list; those will be used to replace the real CompetitorDTO objects where possible and will be replaced the other
|
||||
// way in apply(...).
|
||||
Map<CompetitorDTO, CompetitorDTO> compactCompetitorMap = new HashMap<CompetitorDTO, CompetitorDTO>();
|
||||
int i=0;
|
||||
for (CompetitorDTO competitor : competitors) {
|
||||
int indexInPrevious = previousVersion.competitors.indexOf(competitor);
|
||||
competitorIndexesInPreviousCompetitorsList[i++] = indexInPrevious;
|
||||
if (indexInPrevious == -1) {
|
||||
if (addedCompetitors == null) {
|
||||
addedCompetitors = new ArrayList<CompetitorDTO>();
|
||||
}
|
||||
addedCompetitors.add(competitor);
|
||||
compactCompetitorMap.put(competitor, competitor);
|
||||
} else {
|
||||
CompetitorDTO compactReplacementCompetitor = new PreviousCompetitorDTOImpl(indexInPrevious);
|
||||
compactCompetitorMap.put(competitor, compactReplacementCompetitor);
|
||||
}
|
||||
}
|
||||
competitors = null;
|
||||
if (Util.equalsWithNull(getSuppressedCompetitors(), previousVersion.getSuppressedCompetitors())) {
|
||||
suppressedCompetitorsUnchanged = true;
|
||||
setSuppressedCompetitors(null);
|
||||
} else {
|
||||
List<CompetitorDTO> compactSuppressedCompetitors = new ArrayList<CompetitorDTO>();
|
||||
for (CompetitorDTO suppressedCompetitor : getSuppressedCompetitors()) {
|
||||
final int indexOfSuppressedCompetitorInPreviousSuppressed = Util.indexOf(previousVersion.getSuppressedCompetitors(), suppressedCompetitor);
|
||||
if (indexOfSuppressedCompetitorInPreviousSuppressed == -1) {
|
||||
// not found in previous version's suppressed competitors; maybe it just transitioned from non-suppressed to suppressed
|
||||
final CompetitorDTO compactedFromPreviousCompetitors = compactCompetitorMap.get(suppressedCompetitor);
|
||||
if (compactedFromPreviousCompetitors != null) {
|
||||
compactSuppressedCompetitors.add(compactedFromPreviousCompetitors);
|
||||
} else {
|
||||
compactSuppressedCompetitors.add(suppressedCompetitor);
|
||||
}
|
||||
} else {
|
||||
compactSuppressedCompetitors.add(new PreviousSuppressedCompetitorDTOImpl(
|
||||
indexOfSuppressedCompetitorInPreviousSuppressed));
|
||||
}
|
||||
}
|
||||
setSuppressedCompetitors(compactSuppressedCompetitors);
|
||||
}
|
||||
if (Util.equalsWithNull(competitorDisplayNames, previousVersion.competitorDisplayNames)) {
|
||||
competitorDisplayNamesUnchanged = true;
|
||||
competitorDisplayNames = null;
|
||||
} else {
|
||||
Map<CompetitorDTO, String> compactCompetitorDisplayNames = new HashMap<CompetitorDTO, String>();
|
||||
for (Map.Entry<CompetitorDTO, String> e : competitorDisplayNames.entrySet()) {
|
||||
compactCompetitorDisplayNames.put(compactCompetitorMap.get(e.getKey()), e.getValue());
|
||||
}
|
||||
competitorDisplayNames = compactCompetitorDisplayNames;
|
||||
}
|
||||
raceColumnNamesForWhichCompetitorOrderingPerRaceUnchanged = new HashSet<String>();
|
||||
final HashMap<RaceColumnDTO, List<CompetitorDTO>> competitorOrderingPerRace = new HashMap<RaceColumnDTO, List<CompetitorDTO>>(getCompetitorOrderingPerRace());
|
||||
for (RaceColumnDTO raceColumn : this.getRaceList()) {
|
||||
List<CompetitorDTO> competitorsFromBestToWorstForRaceColumn = getCompetitorsFromBestToWorst(raceColumn);
|
||||
List<CompetitorDTO> previousCompetitorsFromBestToWorstForRaceColumn = previousVersion.getCompetitorsFromBestToWorst(previousVersion.getRaceColumnByName(raceColumn.getName()));
|
||||
if (Util.equalsWithNull(competitorsFromBestToWorstForRaceColumn, previousCompetitorsFromBestToWorstForRaceColumn)) {
|
||||
raceColumnNamesForWhichCompetitorOrderingPerRaceUnchanged.add(raceColumn.getName());
|
||||
competitorOrderingPerRace.remove(raceColumn);
|
||||
} else {
|
||||
// try at least partial compaction
|
||||
List<CompetitorDTO> compactedCompetitorsFromBestToWorstForRaceColumn = new ArrayList<CompetitorDTO>();
|
||||
for (CompetitorDTO competitor : competitorsFromBestToWorstForRaceColumn) {
|
||||
compactedCompetitorsFromBestToWorstForRaceColumn.add(compactCompetitorMap.get(competitor));
|
||||
}
|
||||
competitorOrderingPerRace.put(raceColumn, compactedCompetitorsFromBestToWorstForRaceColumn);
|
||||
}
|
||||
}
|
||||
setCompetitorOrderingPerRace(competitorOrderingPerRace);
|
||||
// now clone the rows map to enable stripping the LeaderboardEntryDTOs inside
|
||||
HashMap<CompetitorDTO, LeaderboardRowDTO> newRows = new HashMap<CompetitorDTO, LeaderboardRowDTO>();
|
||||
for (Map.Entry<CompetitorDTO, LeaderboardRowDTO> competitorAndRow : rows.entrySet()) {
|
||||
LeaderboardRowDTO previousRowDTO = previousVersion.rows.get(competitorAndRow.getKey());
|
||||
if (Util.equalsWithNull(competitorAndRow.getValue(), previousRowDTO)) {
|
||||
entireRowUnchanged(previousVersion, competitorAndRow.getKey());
|
||||
// And don't enter into newRows. Mark all entries and all leg details in this row as unchanged for compaction of those structures:
|
||||
} else {
|
||||
LeaderboardRowDTO newRowDTO = new LeaderboardRowDTO();
|
||||
cloner.clone(competitorAndRow.getValue(), newRowDTO);
|
||||
CompetitorDTO compactCompetitor = compactCompetitorMap.get(competitorAndRow.getKey());
|
||||
newRowDTO.competitor = compactCompetitor;
|
||||
newRows.put(compactCompetitor, newRowDTO);
|
||||
HashMap<String, LeaderboardEntryDTO> newFieldsByRaceColumnName = new HashMap<String, LeaderboardEntryDTO>();
|
||||
for (Map.Entry<String, LeaderboardEntryDTO> raceColumnNameAndLeaderboardEntry : newRowDTO.fieldsByRaceColumnName.entrySet()) {
|
||||
LeaderboardEntryDTO previousEntryDTO = null;
|
||||
if (previousRowDTO != null) {
|
||||
previousEntryDTO = previousRowDTO.fieldsByRaceColumnName.get(raceColumnNameAndLeaderboardEntry.getKey());
|
||||
}
|
||||
if (previousEntryDTO != null
|
||||
&& Util.equalsWithNull(raceColumnNameAndLeaderboardEntry.getValue(), previousEntryDTO)) {
|
||||
getUnchangedLeaderboardEntries(previousVersion).unchanged(competitorAndRow.getKey(),
|
||||
raceColumnNameAndLeaderboardEntry.getKey());
|
||||
// also mark all leg details for the competitor for this column as unchanged; this will ensure
|
||||
// that column compression can work for leg details
|
||||
getLegDetailsUnchanged(previousVersion).unchanged(competitorAndRow.getKey(),
|
||||
new Pair<String, Integer>(raceColumnNameAndLeaderboardEntry.getKey(), null));
|
||||
} else {
|
||||
LeaderboardEntryDTO newLeaderboardEntryDTO = new LeaderboardEntryDTO();
|
||||
cloner.clone(raceColumnNameAndLeaderboardEntry.getValue(), newLeaderboardEntryDTO);
|
||||
newFieldsByRaceColumnName.put(raceColumnNameAndLeaderboardEntry.getKey(), newLeaderboardEntryDTO);
|
||||
if (newLeaderboardEntryDTO.legDetails != null) {
|
||||
for (int legDetailsIndex = 0; legDetailsIndex < newLeaderboardEntryDTO.legDetails.size(); legDetailsIndex++) {
|
||||
LegEntryDTO legDetails = newLeaderboardEntryDTO.legDetails.get(legDetailsIndex);
|
||||
if (previousEntryDTO != null
|
||||
&& previousEntryDTO.legDetails != null
|
||||
&& Util.equalsWithNull(legDetails,
|
||||
previousEntryDTO.legDetails.get(legDetailsIndex))) {
|
||||
getLegDetailsUnchanged(previousVersion).unchanged(
|
||||
competitorAndRow.getKey(),
|
||||
new Pair<String, Integer>(raceColumnNameAndLeaderboardEntry.getKey(),
|
||||
legDetailsIndex));
|
||||
newLeaderboardEntryDTO.legDetails.set(legDetailsIndex, null);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (previousEntryDTO == null || previousEntryDTO.legDetails == null) {
|
||||
// old and new entry are null; no need to set the legDetails in the new version to null
|
||||
// as it already consumes no space;
|
||||
// however, mark the legDetails as unchanged in legDetailsUnchanged so as to allow for
|
||||
// all-column compression
|
||||
getLegDetailsUnchanged(previousVersion).unchanged(competitorAndRow.getKey(),
|
||||
new Pair<String, Integer>(raceColumnNameAndLeaderboardEntry.getKey(), null));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
newRowDTO.fieldsByRaceColumnName = newFieldsByRaceColumnName;
|
||||
}
|
||||
}
|
||||
rows = newRows.isEmpty() ? null : newRows;
|
||||
if (legDetailsUnchanged != null) {
|
||||
legDetailsUnchanged.compact(); // compacts even those columns where the *last* entry was one with a null leg index
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Marks the <code>competitor</code>'s row as unchanged in the {@link #rowsUnchanged} structure as well as for all
|
||||
* races and legs in {@link #legDetailsUnchanged} and {@link #unchangedLeaderboardEntries} so that compaction of
|
||||
* those structures can happen accordingly. The races/legs can only be marked as unchanged if the row is not
|
||||
* <code>null</code>.
|
||||
*/
|
||||
private void entireRowUnchanged(LeaderboardDTO previousVersion, CompetitorDTO competitor) {
|
||||
if (rowsUnchanged == null) {
|
||||
rowsUnchanged = new UnchangedWithCompetitorsInBitSet<Void>(previousVersion, rows.size());
|
||||
}
|
||||
rowsUnchanged.unchanged(competitor, null);
|
||||
LeaderboardRowDTO row = rows.get(competitor);
|
||||
if (row != null && row.fieldsByRaceColumnName != null) {
|
||||
for (Map.Entry<String, LeaderboardEntryDTO> e : row.fieldsByRaceColumnName.entrySet()) {
|
||||
getUnchangedLeaderboardEntries(previousVersion).unchanged(competitor, e.getKey());
|
||||
getLegDetailsUnchanged(previousVersion).unchanged(competitor, new Pair<String, Integer>(e.getKey(), /* all legs unchanged */ null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private UnchangedWithCompetitorsInBitSet<String> getUnchangedLeaderboardEntries(LeaderboardDTO previousVersion) {
|
||||
if (unchangedLeaderboardEntries == null) {
|
||||
unchangedLeaderboardEntries = new UnchangedWithCompetitorsInBitSet<String>(previousVersion, rows.size());
|
||||
}
|
||||
return unchangedLeaderboardEntries;
|
||||
}
|
||||
|
||||
private UnchangedLegDetails getLegDetailsUnchanged(LeaderboardDTO previousVersion) {
|
||||
if (legDetailsUnchanged == null) {
|
||||
legDetailsUnchanged = new UnchangedLegDetails(previousVersion, rows.size());
|
||||
}
|
||||
return legDetailsUnchanged;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Allows for incremental serialization of a {@link LeaderboardDTO} by providing an implementation that refers to a previous
|
||||
* version and provides only updates, or alternatively sending the full leaderboard.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public interface IncrementalOrFullLeaderboardDTO extends Serializable {
|
||||
/**
|
||||
* Produces the leaderboard DTO by providing the previous version relative to which a delta was requested.
|
||||
* If <code>null</code> was used to identify the previous version, <code>null</code> may be passed for
|
||||
* <code>previousVersion</code> here as well because a full leaderboard will have been transmitted anyhow.
|
||||
* Passing a <code>null</code> value when a non-<code>null</code> previous leaderboard identifier was used
|
||||
* to request this object will result in an {@link IllegalArgumentException}.
|
||||
*/
|
||||
LeaderboardDTO getLeaderboardDTO(LeaderboardDTO previousVersion);
|
||||
}
|
||||
+54
-9
@@ -1,12 +1,11 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Captures the serializable properties of a leaderboard which in particular has the competitors, any optional display
|
||||
@@ -18,20 +17,33 @@ import java.util.Set;
|
||||
*/
|
||||
public class LeaderboardDTO extends AbstractLeaderboardDTO implements Serializable {
|
||||
private static final long serialVersionUID = -520930809792750648L;
|
||||
|
||||
|
||||
public interface UUIDGenerator {
|
||||
String generateRandomUUID();
|
||||
}
|
||||
|
||||
/**
|
||||
* A unique ID, obtained by applying <code>toString</code> to an object of type <code>java.util.UUID</code>.
|
||||
* When {@link #clone} is called on this object, a new ID is generated for the result.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* The competitor list, ordered ascending by total rank
|
||||
*/
|
||||
public List<CompetitorDTO> competitors;
|
||||
|
||||
private Set<CompetitorDTO> suppressedCompetitors;
|
||||
/**
|
||||
* A list with set semantics; no duplicates are allowed.
|
||||
*/
|
||||
private List<CompetitorDTO> suppressedCompetitors;
|
||||
|
||||
private Map<RaceColumnDTO, List<CompetitorDTO>> competitorOrderingPerRace;
|
||||
|
||||
private Date timePointOfLastCorrectionsValidity;
|
||||
|
||||
private String comment;
|
||||
|
||||
|
||||
/**
|
||||
* Taken from the scoring scheme. Shall be used by the race columns to control their initial sort order.
|
||||
*/
|
||||
@@ -39,20 +51,45 @@ public class LeaderboardDTO extends AbstractLeaderboardDTO implements Serializab
|
||||
|
||||
LeaderboardDTO() {} // for serialization
|
||||
|
||||
public LeaderboardDTO(Date timePointOfLastCorrectionsValidity, String comment, boolean higherScoreIsBetter) {
|
||||
/**
|
||||
* @param uuidGenerator used to provide the {@link #id ID} for this object (see also {@link #getId()}) and for any clones produced
|
||||
* from it by the {@link #clone()} operation.
|
||||
*/
|
||||
public LeaderboardDTO(Date timePointOfLastCorrectionsValidity, String comment, boolean higherScoreIsBetter, UUIDGenerator uuidGenerator) {
|
||||
initCollections();
|
||||
id = uuidGenerator.generateRandomUUID();
|
||||
this.timePointOfLastCorrectionsValidity = timePointOfLastCorrectionsValidity;
|
||||
this.comment = comment;
|
||||
competitorOrderingPerRace = new HashMap<RaceColumnDTO, List<CompetitorDTO>>();
|
||||
this.suppressedCompetitors = new HashSet<CompetitorDTO>();
|
||||
this.higherScoresIsBetter = higherScoreIsBetter;
|
||||
}
|
||||
|
||||
private void initCollections() {
|
||||
competitorOrderingPerRace = new HashMap<RaceColumnDTO, List<CompetitorDTO>>();
|
||||
this.suppressedCompetitors = new ArrayList<CompetitorDTO>();
|
||||
}
|
||||
|
||||
public LeaderboardDTO(String id) {
|
||||
initCollections();
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public Iterable<CompetitorDTO> getSuppressedCompetitors() {
|
||||
return suppressedCompetitors;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param suppressedCompetitors must not contain any duplicates ("set" semantics)
|
||||
*/
|
||||
public void setSuppressedCompetitors(List<CompetitorDTO> suppressedCompetitors) {
|
||||
this.suppressedCompetitors = suppressedCompetitors;
|
||||
}
|
||||
|
||||
public void setSuppressed(CompetitorDTO competitor, boolean suppressed) {
|
||||
if (suppressed) {
|
||||
if (suppressed && !suppressedCompetitors.contains(competitor)) {
|
||||
suppressedCompetitors.add(competitor);
|
||||
} else {
|
||||
suppressedCompetitors.remove(competitor);
|
||||
@@ -66,7 +103,15 @@ public class LeaderboardDTO extends AbstractLeaderboardDTO implements Serializab
|
||||
public void setCompetitorsFromBestToWorst(RaceColumnDTO raceColumn, List<CompetitorDTO> orderedCompetitors) {
|
||||
competitorOrderingPerRace.put(raceColumn, orderedCompetitors);
|
||||
}
|
||||
|
||||
public void setCompetitorOrderingPerRace(Map<RaceColumnDTO, List<CompetitorDTO>> competitorOrderingPerRace) {
|
||||
this.competitorOrderingPerRace = competitorOrderingPerRace;
|
||||
}
|
||||
|
||||
public Map<RaceColumnDTO, List<CompetitorDTO>> getCompetitorOrderingPerRace() {
|
||||
return competitorOrderingPerRace;
|
||||
}
|
||||
|
||||
public List<CompetitorDTO> getCompetitorsFromBestToWorst(RaceColumnDTO raceColumn) {
|
||||
return competitorOrderingPerRace.get(raceColumn);
|
||||
}
|
||||
|
||||
+53
-2
@@ -38,8 +38,6 @@ public class LeaderboardEntryDTO implements Serializable {
|
||||
|
||||
public Double totalPoints;
|
||||
|
||||
public Integer rank;
|
||||
|
||||
public boolean discarded;
|
||||
|
||||
public Double windwardDistanceToOverallLeaderInMeters;
|
||||
@@ -83,9 +81,27 @@ public class LeaderboardEntryDTO implements Serializable {
|
||||
result = prime * result
|
||||
+ ((averageCrossTrackErrorInMeters == null) ? 0 : averageCrossTrackErrorInMeters.hashCode());
|
||||
result = prime * result + (discarded ? 1231 : 1237);
|
||||
result = prime
|
||||
* result
|
||||
+ ((distanceToStarboardSideOfStartLineInMeters == null) ? 0
|
||||
: distanceToStarboardSideOfStartLineInMeters.hashCode());
|
||||
result = prime
|
||||
* result
|
||||
+ ((distanceToStartLineAtStartOfRaceInMeters == null) ? 0 : distanceToStartLineAtStartOfRaceInMeters
|
||||
.hashCode());
|
||||
result = prime * result + ((fleet == null) ? 0 : fleet.hashCode());
|
||||
result = prime * result + ((legDetails == null) ? 0 : legDetails.hashCode());
|
||||
result = prime * result + ((netPoints == null) ? 0 : netPoints.hashCode());
|
||||
result = prime * result + (netPointsCorrected ? 1231 : 1237);
|
||||
result = prime * result + ((race == null) ? 0 : race.hashCode());
|
||||
result = prime * result + ((reasonForMaxPoints == null) ? 0 : reasonForMaxPoints.hashCode());
|
||||
result = prime
|
||||
* result
|
||||
+ ((speedOverGroundAtPassingStartWaypointInKnots == null) ? 0
|
||||
: speedOverGroundAtPassingStartWaypointInKnots.hashCode());
|
||||
result = prime * result
|
||||
+ ((speedOverGroundAtStartOfRaceInKnots == null) ? 0 : speedOverGroundAtStartOfRaceInKnots.hashCode());
|
||||
result = prime * result + ((startTack == null) ? 0 : startTack.hashCode());
|
||||
result = prime * result + ((totalPoints == null) ? 0 : totalPoints.hashCode());
|
||||
result = prime
|
||||
* result
|
||||
@@ -110,6 +126,21 @@ public class LeaderboardEntryDTO implements Serializable {
|
||||
return false;
|
||||
if (discarded != other.discarded)
|
||||
return false;
|
||||
if (distanceToStarboardSideOfStartLineInMeters == null) {
|
||||
if (other.distanceToStarboardSideOfStartLineInMeters != null)
|
||||
return false;
|
||||
} else if (!distanceToStarboardSideOfStartLineInMeters.equals(other.distanceToStarboardSideOfStartLineInMeters))
|
||||
return false;
|
||||
if (distanceToStartLineAtStartOfRaceInMeters == null) {
|
||||
if (other.distanceToStartLineAtStartOfRaceInMeters != null)
|
||||
return false;
|
||||
} else if (!distanceToStartLineAtStartOfRaceInMeters.equals(other.distanceToStartLineAtStartOfRaceInMeters))
|
||||
return false;
|
||||
if (fleet == null) {
|
||||
if (other.fleet != null)
|
||||
return false;
|
||||
} else if (!fleet.equals(other.fleet))
|
||||
return false;
|
||||
if (legDetails == null) {
|
||||
if (other.legDetails != null)
|
||||
return false;
|
||||
@@ -120,8 +151,28 @@ public class LeaderboardEntryDTO implements Serializable {
|
||||
return false;
|
||||
} else if (!netPoints.equals(other.netPoints))
|
||||
return false;
|
||||
if (netPointsCorrected != other.netPointsCorrected)
|
||||
return false;
|
||||
if (race == null) {
|
||||
if (other.race != null)
|
||||
return false;
|
||||
} else if (!race.equals(other.race))
|
||||
return false;
|
||||
if (reasonForMaxPoints != other.reasonForMaxPoints)
|
||||
return false;
|
||||
if (speedOverGroundAtPassingStartWaypointInKnots == null) {
|
||||
if (other.speedOverGroundAtPassingStartWaypointInKnots != null)
|
||||
return false;
|
||||
} else if (!speedOverGroundAtPassingStartWaypointInKnots
|
||||
.equals(other.speedOverGroundAtPassingStartWaypointInKnots))
|
||||
return false;
|
||||
if (speedOverGroundAtStartOfRaceInKnots == null) {
|
||||
if (other.speedOverGroundAtStartOfRaceInKnots != null)
|
||||
return false;
|
||||
} else if (!speedOverGroundAtStartOfRaceInKnots.equals(other.speedOverGroundAtStartOfRaceInKnots))
|
||||
return false;
|
||||
if (startTack != other.startTack)
|
||||
return false;
|
||||
if (totalPoints == null) {
|
||||
if (other.totalPoints != null)
|
||||
return false;
|
||||
|
||||
+2
-1
@@ -61,7 +61,8 @@ public class LegEntryDTO implements Serializable {
|
||||
* result
|
||||
+ ((estimatedTimeToNextWaypointInSeconds == null) ? 0 : estimatedTimeToNextWaypointInSeconds.hashCode());
|
||||
result = prime * result + (finished ? 1231 : 1237);
|
||||
result = prime * result + ((gapChangeSinceLegStartInSeconds == null) ? 0 : gapChangeSinceLegStartInSeconds.hashCode());
|
||||
result = prime * result
|
||||
+ ((gapChangeSinceLegStartInSeconds == null) ? 0 : gapChangeSinceLegStartInSeconds.hashCode());
|
||||
result = prime * result + ((gapToLeaderInSeconds == null) ? 0 : gapToLeaderInSeconds.hashCode());
|
||||
result = prime * result + ((numberOfManeuvers == null) ? 0 : numberOfManeuvers.hashCode());
|
||||
result = prime * result + rank;
|
||||
|
||||
+14
-6
@@ -4,7 +4,7 @@ import java.io.Serializable;
|
||||
|
||||
public class NamedDTO implements Serializable {
|
||||
private static final long serialVersionUID = -6620231501480297257L;
|
||||
public String name;
|
||||
private String name;
|
||||
|
||||
public NamedDTO() {}
|
||||
|
||||
@@ -14,14 +14,14 @@ public class NamedDTO implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
return getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -34,12 +34,20 @@ public class NamedDTO implements Serializable {
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
NamedDTO other = (NamedDTO) obj;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
if (getName() == null) {
|
||||
if (other.getName() != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
} else if (!getName().equals(other.getName()))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -46,12 +46,12 @@ public class PlacemarkDTO extends NamedDTO {
|
||||
* @return The placemark as string with the format '<code>countryCode</code> , <code>name</code>'
|
||||
*/
|
||||
public String asString() {
|
||||
return countryCode + ", " + name;
|
||||
return countryCode + ", " + getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return countryCode + ", " + name + ", " + population + ", " + position.toString();
|
||||
return countryCode + ", " + getName() + ", " + population + ", " + position.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
public class PreviousCompetitorDTOImpl implements CompetitorDTO {
|
||||
private static final long serialVersionUID = 8820028699103040805L;
|
||||
private int indexInPreviousCompetitorList;
|
||||
|
||||
PreviousCompetitorDTOImpl() {} // for serialization only
|
||||
|
||||
public PreviousCompetitorDTOImpl(int indexInPreviousCompetitorList) {
|
||||
super();
|
||||
this.indexInPreviousCompetitorList = indexInPreviousCompetitorList;
|
||||
}
|
||||
|
||||
protected int getIndexInPreviousCompetitorList() {
|
||||
return indexInPreviousCompetitorList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTwoLetterIsoCountryCode() {
|
||||
throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+
|
||||
" need to be replaced by an object of "+CompetitorDTOImpl.class.getName()+" after deserialization");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getThreeLetterIocCountryCode() {
|
||||
throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+
|
||||
" need to be replaced by an object of "+CompetitorDTOImpl.class.getName()+" after deserialization");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCountryName() {
|
||||
throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+
|
||||
" need to be replaced by an object of "+CompetitorDTOImpl.class.getName()+" after deserialization");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSailID() {
|
||||
throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+
|
||||
" need to be replaced by an object of "+CompetitorDTOImpl.class.getName()+" after deserialization");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getIdAsString() {
|
||||
throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+
|
||||
" need to be replaced by an object of "+CompetitorDTOImpl.class.getName()+" after deserialization");
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatClassDTO getBoatClass() {
|
||||
throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+
|
||||
" need to be replaced by an object of "+CompetitorDTOImpl.class.getName()+" after deserialization");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+
|
||||
" need to be replaced by an object of "+CompetitorDTOImpl.class.getName()+" after deserialization");
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorDTO getCompetitorFromPrevious(LeaderboardDTO previousVersion) {
|
||||
return previousVersion.competitors.get(indexInPreviousCompetitorList);
|
||||
}
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.sap.sailing.domain.common.dto;
|
||||
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
|
||||
/**
|
||||
* Like the superclass, but competitors are fetched from the {@link LeaderboardDTO#getSuppressedCompetitors()} list
|
||||
* instead of the {@link LeaderboardDTO#competitors} list where suppressed competitors don't show.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class PreviousSuppressedCompetitorDTOImpl extends PreviousCompetitorDTOImpl {
|
||||
private static final long serialVersionUID = -4879238928633525593L;
|
||||
|
||||
PreviousSuppressedCompetitorDTOImpl() {
|
||||
super();
|
||||
}
|
||||
|
||||
public PreviousSuppressedCompetitorDTOImpl(int indexInPreviousCompetitorList) {
|
||||
super(indexInPreviousCompetitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompetitorDTO getCompetitorFromPrevious(LeaderboardDTO previousVersion) {
|
||||
return Util.get(previousVersion.getSuppressedCompetitors(), getIndexInPreviousCompetitorList());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+18
-5
@@ -52,7 +52,7 @@ public class RaceColumnDTO extends NamedDTO implements Serializable {
|
||||
}
|
||||
|
||||
public String getRaceColumnName() {
|
||||
return name;
|
||||
return getName();
|
||||
}
|
||||
|
||||
public Double getExplicitFactor() {
|
||||
@@ -202,13 +202,26 @@ public class RaceColumnDTO extends NamedDTO implements Serializable {
|
||||
int result = 1;
|
||||
result = prime * result + ((fleets == null) ? 0 : fleets.hashCode());
|
||||
result = prime * result + (medalRace ? 1231 : 1237);
|
||||
result = prime * result + ((name == null) ? 0 : name.hashCode());
|
||||
result = prime * result + ((getName() == null) ? 0 : getName().hashCode());
|
||||
result = prime * result + ((racesPerFleet == null) ? 0 : racesPerFleet.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
final boolean result;
|
||||
if (this == obj) {
|
||||
result = true;
|
||||
} else {
|
||||
result = equals2(obj);
|
||||
if (result) {
|
||||
int i=0; i = i+1; // TODO remove this code which is only used to set a breakpoint here...
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private boolean equals2(Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
@@ -223,10 +236,10 @@ public class RaceColumnDTO extends NamedDTO implements Serializable {
|
||||
return false;
|
||||
if (medalRace != other.medalRace)
|
||||
return false;
|
||||
if (name == null) {
|
||||
if (other.name != null)
|
||||
if (getName() == null) {
|
||||
if (other.getName() != null)
|
||||
return false;
|
||||
} else if (!name.equals(other.name))
|
||||
} else if (!getName().equals(other.getName()))
|
||||
return false;
|
||||
if (racesPerFleet == null) {
|
||||
if (other.racesPerFleet != null)
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ public class RaceDTO extends NamedDTO {
|
||||
}
|
||||
|
||||
public RegattaAndRaceIdentifier getRaceIdentifier() {
|
||||
return new RegattaNameAndRaceName(regattaName, name);
|
||||
return new RegattaNameAndRaceName(regattaName, getName());
|
||||
}
|
||||
|
||||
public String getRegattaName() {
|
||||
|
||||
-6
@@ -1,7 +1,6 @@
|
||||
package com.sap.sailing.domain.common.impl;
|
||||
|
||||
import com.sap.sailing.domain.common.AbstractSpeedImpl;
|
||||
import com.sap.sailing.domain.common.Mile;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
|
||||
public class KilometersPerHourSpeedImpl extends AbstractSpeedImpl implements Speed {
|
||||
@@ -12,11 +11,6 @@ public class KilometersPerHourSpeedImpl extends AbstractSpeedImpl implements Spe
|
||||
this.speedInKilometersPerHour = speedInKilometersPerHour;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getKnots() {
|
||||
return getKilometersPerHour() * 1000. / Mile.METERS_PER_NAUTICAL_MILE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMetersPerSecond() {
|
||||
return getKilometersPerHour() / 3.6;
|
||||
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
package com.sap.sailing.domain.common.impl;
|
||||
|
||||
import com.sap.sailing.domain.common.AbstractSpeedImpl;
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
|
||||
public class MeterPerSecondSpeedImpl extends AbstractSpeedImpl implements Speed {
|
||||
private static final long serialVersionUID = -524654796500981303L;
|
||||
private final double metersPerSecond;
|
||||
|
||||
public MeterPerSecondSpeedImpl(double metersPerSecond) {
|
||||
this.metersPerSecond = metersPerSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMetersPerSecond() {
|
||||
return metersPerSecond;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getKilometersPerHour() {
|
||||
return metersPerSecond/3.6;
|
||||
}
|
||||
}
|
||||
@@ -232,4 +232,18 @@ public class Util {
|
||||
}
|
||||
|
||||
|
||||
public static boolean equalsWithNull(Object o1, Object o2) {
|
||||
final boolean result;
|
||||
if (o1 == null) {
|
||||
result = (o2 == null);
|
||||
} else {
|
||||
if (o2 == null) {
|
||||
result = false;
|
||||
} else {
|
||||
result = o1.equals(o2);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
+52
-14
@@ -1,15 +1,16 @@
|
||||
package com.sap.sailing.gwt.ui.client.shared.media;
|
||||
package com.sap.sailing.domain.common.media;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.user.client.rpc.IsSerializable;
|
||||
|
||||
/**
|
||||
* See http://my.opera.com/core/blog/2010/03/03/everything-you-need-to-know-about-html5-video-and-audio-2
|
||||
* @author D047974
|
||||
*
|
||||
*/
|
||||
public class MediaTrack implements IsSerializable {
|
||||
public class MediaTrack implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public enum MimeType {
|
||||
|
||||
@@ -56,13 +57,6 @@ public class MediaTrack implements IsSerializable {
|
||||
}
|
||||
}
|
||||
|
||||
public class MediaSection implements IsSerializable {
|
||||
public String title;
|
||||
public long offsetInMillis;
|
||||
public Date startTime;
|
||||
public Date endTime;
|
||||
}
|
||||
|
||||
public String dbId;
|
||||
public String title;
|
||||
public String url;
|
||||
@@ -72,11 +66,17 @@ public class MediaTrack implements IsSerializable {
|
||||
public Status status = Status.UNDEFINED;
|
||||
|
||||
public MediaTrack() {
|
||||
super();
|
||||
}
|
||||
|
||||
|
||||
public MediaTrack(String title, String url, Date startTime, int durationInMillis, MimeType mimeType) {
|
||||
this.title = title;
|
||||
this.url = url;
|
||||
this.startTime = startTime;
|
||||
this.durationInMillis = durationInMillis;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
public MediaTrack(String dbId, String title, String url, Date startTime, int durationInMillis, MimeType mimeType) {
|
||||
super();
|
||||
this.dbId = dbId;
|
||||
this.title = title;
|
||||
this.url = url;
|
||||
@@ -88,6 +88,14 @@ public class MediaTrack implements IsSerializable {
|
||||
public String toString() {
|
||||
return title + " - " + url + " [" + typeToString() + ']' + startTime + " [" + durationInMillis + status + ']';
|
||||
}
|
||||
|
||||
public Date deriveEndTime() {
|
||||
if (startTime != null) {
|
||||
return new Date(startTime.getTime() + durationInMillis);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String typeToString() {
|
||||
return mimeType == null ? "undefined" : mimeType.toString();
|
||||
@@ -96,5 +104,35 @@ public class MediaTrack implements IsSerializable {
|
||||
public boolean isYoutube() {
|
||||
return (mimeType != null) && MediaSubType.youtube.equals(mimeType.mediaSubType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks for overlap of this start time and duration with the given startTime and endTime, excluding boundaries!
|
||||
* Behaviour for given endTime being earlier than given startTime is not specified.
|
||||
* endTime being null represents "open end". Open beginning is not allow, though!
|
||||
* @param startTime Must not be null.
|
||||
* @param endTime May be null representing "open end".
|
||||
*/
|
||||
public boolean overlapsWith(Date startTime, Date endTime) {
|
||||
if (this.startTime == null) {
|
||||
return false;
|
||||
} else {
|
||||
return this.deriveEndTime().getTime() > startTime.getTime() && (endTime == null || this.startTime.getTime() < endTime.getTime());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj instanceof MediaTrack) {
|
||||
MediaTrack mediaTrack = (MediaTrack) obj;
|
||||
return this.dbId == null? mediaTrack.dbId == null : this.dbId.equals(mediaTrack.dbId);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.dbId == null ? 0 : this.dbId.hashCode();
|
||||
}
|
||||
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.sap.sailing.domain.common.media;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
public class MediaUtil {
|
||||
|
||||
public static int compareDatesAllowingNull(Date date1, Date date2) {
|
||||
if (date1 == null) {
|
||||
return date2 == null ? 0 : -1;
|
||||
} else if (date2 == null) {
|
||||
return 1;
|
||||
} else {
|
||||
return date1.compareTo(date2);
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean equalsDatesAllowingNull(Date date1, Date date2) {
|
||||
if (date1 == null) {
|
||||
return date2 == null;
|
||||
} else if (date2 == null) {
|
||||
return false;
|
||||
} else {
|
||||
return date1.equals(date2);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
+31
-5
@@ -1,6 +1,6 @@
|
||||
package com.sap.sailing.domain.persistence.media;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -14,11 +14,9 @@ public interface MediaDB {
|
||||
|
||||
String insertMediaTrack(String title, String url, Date startTime, int durationInMillis, String mimeType);
|
||||
|
||||
DBMediaTrack loadMediaTrack(String dbId);
|
||||
|
||||
List<DBMediaTrack> loadAllMediaTracks();
|
||||
|
||||
void deleteMediaTrack(String title);
|
||||
void deleteMediaTrack(String dbId);
|
||||
|
||||
void updateTitle(String dbId, String title);
|
||||
|
||||
@@ -28,6 +26,34 @@ public interface MediaDB {
|
||||
|
||||
void updateDuration(String dbId, int durationInMillis);
|
||||
|
||||
Collection<DBMediaTrack> queryOverlappingMediaTracks(Date rangeStart, Date rangeEnd);
|
||||
MediaDB TEST_STUB = new MediaDB() {
|
||||
|
||||
@Override
|
||||
public String insertMediaTrack(String title, String url, Date startTime, int durationInMillis, String mimeType) {
|
||||
return "0";
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DBMediaTrack> loadAllMediaTracks() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteMediaTrack(String dbId) {}
|
||||
|
||||
@Override
|
||||
public void updateTitle(String dbId, String title) {}
|
||||
|
||||
@Override
|
||||
public void updateUrl(String dbId, String url) {}
|
||||
|
||||
@Override
|
||||
public void updateStartTime(String dbId, Date startTime) {}
|
||||
|
||||
@Override
|
||||
public void updateDuration(String dbId, int durationInMillis) {}
|
||||
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
-2
@@ -6,8 +6,6 @@ import com.sap.sailing.mongodb.MongoDBService;
|
||||
public interface MediaDBFactory {
|
||||
MediaDBFactory INSTANCE = new MediaDBFactoryImpl();
|
||||
|
||||
MediaObjectFactory getDefaultDomainObjectFactory();
|
||||
MediaObjectFactory getDomainObjectFactory(MongoDBService mongoDBService);
|
||||
MediaDB getDefaultMediaDB();
|
||||
MediaDB getMediaDB(MongoDBService mongoDBService);
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
package com.sap.sailing.domain.persistence.media;
|
||||
|
||||
|
||||
/**
|
||||
* Offers methods to load media objects from a Mongo DB
|
||||
*
|
||||
* @author Jens Rommel (d047974)
|
||||
*
|
||||
*/
|
||||
public interface MediaObjectFactory {
|
||||
}
|
||||
-50
@@ -1,50 +0,0 @@
|
||||
package com.sap.sailing.domain.persistence.media.impl;
|
||||
|
||||
/**
|
||||
* Defines literals providing the names for MongoDB collections. The literal documentation described the semantics
|
||||
* of the collection identified by that literal.
|
||||
*
|
||||
* @author Axel Uhl (D043530)
|
||||
*
|
||||
*/
|
||||
public enum CollectionNames {
|
||||
/**
|
||||
* Stores the wind fixes recorded from persistent wind sources.
|
||||
*/
|
||||
WIND_TRACKS,
|
||||
|
||||
/**
|
||||
* Stores the leaderboards with their names, score corrections, competitor display name overrides, race
|
||||
* columns and their fleets as well as the per-fleet tracked race assignments.
|
||||
*/
|
||||
LEADERBOARDS,
|
||||
|
||||
/**
|
||||
* Stores the leaderboard group configurations with references to the {@link #LEADERBOARDS} collection
|
||||
*/
|
||||
LEADERBOARD_GROUPS,
|
||||
|
||||
/**
|
||||
* Top-level event information about events such as Kiel Week 2011, or IDM Travem�nde 2011, including name and
|
||||
* course areas.
|
||||
*/
|
||||
EVENTS,
|
||||
|
||||
/**
|
||||
* Stores regatta definitions including their series layout and fleets and race columns. Regattas can reference
|
||||
* the event from the {@link #EVENTS} collection to which they belong.
|
||||
*/
|
||||
REGATTAS,
|
||||
|
||||
/**
|
||||
* Stores boat class-specific master data such as the class's hull length, logo, name, number of sailors, etc.
|
||||
* To be implemented in future versions.
|
||||
*/
|
||||
BOAT_CLASSES,
|
||||
|
||||
/**
|
||||
* Stores the mapping of {@link RaceDefinition#getId race IDs} to regatta names for automatic re-association
|
||||
* when tracking races again without explicitly specifying a regatta.
|
||||
*/
|
||||
REGATTA_FOR_RACE_ID;
|
||||
}
|
||||
-13
@@ -2,29 +2,16 @@ package com.sap.sailing.domain.persistence.media.impl;
|
||||
|
||||
import com.sap.sailing.domain.persistence.media.MediaDB;
|
||||
import com.sap.sailing.domain.persistence.media.MediaDBFactory;
|
||||
import com.sap.sailing.domain.persistence.media.MediaObjectFactory;
|
||||
import com.sap.sailing.mongodb.MongoDBService;
|
||||
|
||||
public class MediaDBFactoryImpl implements MediaDBFactory {
|
||||
private final MediaObjectFactory defaultMediaObjectFactory;
|
||||
private final MediaDB defaultMediaDB;
|
||||
|
||||
public MediaDBFactoryImpl() {
|
||||
super();
|
||||
this.defaultMediaObjectFactory = new MediaObjectFactoryImpl(MongoDBService.INSTANCE.getDB());
|
||||
this.defaultMediaDB = new MediaDBImpl(MongoDBService.INSTANCE.getDB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaObjectFactory getDefaultDomainObjectFactory() {
|
||||
return defaultMediaObjectFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaObjectFactory getDomainObjectFactory(MongoDBService mongoDBService) {
|
||||
return new MediaObjectFactoryImpl(mongoDBService.getDB());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MediaDB getDefaultMediaDB() {
|
||||
return defaultMediaDB;
|
||||
|
||||
-50
@@ -1,8 +1,6 @@
|
||||
package com.sap.sailing.domain.persistence.media.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@@ -13,7 +11,6 @@ import com.mongodb.DB;
|
||||
import com.mongodb.DBCollection;
|
||||
import com.mongodb.DBCursor;
|
||||
import com.mongodb.DBObject;
|
||||
import com.mongodb.QueryBuilder;
|
||||
import com.sap.sailing.domain.persistence.media.DBMediaTrack;
|
||||
import com.sap.sailing.domain.persistence.media.MediaDB;
|
||||
|
||||
@@ -63,23 +60,6 @@ public class MediaDBImpl implements MediaDB {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public DBMediaTrack loadMediaTrack(String dbId) {
|
||||
ObjectId objectId = new ObjectId(dbId);
|
||||
DBCursor cursor = getVideoCollection().find(new BasicDBObject(DbNames.Fields._id.name(), objectId));
|
||||
switch (cursor.count()) {
|
||||
case 0:
|
||||
throw new RuntimeException("Video not found with id: " + dbId);
|
||||
case 1:
|
||||
DBObject dbObject = cursor.next();
|
||||
DBMediaTrack dbMediaTrack = createMediaObjectFromDB(dbObject);
|
||||
return dbMediaTrack;
|
||||
default:
|
||||
throw new RuntimeException("Ambiguous videos not found with id: " + dbId);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private DBMediaTrack createMediaObjectFromDB(DBObject dbObject) {
|
||||
String dbId = ((ObjectId) dbObject.get(DbNames.Fields._id.name())).toString();
|
||||
String title = (String) dbObject.get(DbNames.Fields.MEDIA_TITLE.name());
|
||||
@@ -152,34 +132,4 @@ public class MediaDBImpl implements MediaDB {
|
||||
getVideoCollection().update(updateQuery, update);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<DBMediaTrack> queryOverlappingMediaTracks(Date rangeStart, Date rangeEnd) {
|
||||
if ((rangeStart != null) && (rangeEnd != null)) {
|
||||
BasicDBObject startTimeCondition = new BasicDBObject();
|
||||
startTimeCondition.put(DbNames.Fields.STARTTIME.name(), new BasicDBObject("$gt", rangeStart));
|
||||
startTimeCondition.put(DbNames.Fields.STARTTIME.name(), new BasicDBObject("$lt", rangeEnd));
|
||||
BasicDBObject endTimeCondition = new BasicDBObject();
|
||||
|
||||
// Should actually be "AND greater than rangeStart - duration".
|
||||
// However, using values calculated on server side turns out to be a nightmare with mongodb.
|
||||
// Instead do the remaining filtering on client side...
|
||||
endTimeCondition.put(DbNames.Fields.STARTTIME.name(), new BasicDBObject("$lt", rangeStart));
|
||||
|
||||
DBObject query = QueryBuilder.start().or(startTimeCondition, endTimeCondition).get();
|
||||
|
||||
DBCursor cursor = getVideoCollection().find(query).sort(sortByStartTimeAndTitle);
|
||||
|
||||
List<DBMediaTrack> result = new ArrayList<>(cursor.count());
|
||||
while (cursor.hasNext()) {
|
||||
DBMediaTrack resultCandidate = createMediaObjectFromDB(cursor.next());
|
||||
if (resultCandidate.durationInMillis > rangeStart.getTime() - resultCandidate.startTime.getTime()) {
|
||||
result.add(resultCandidate);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
package com.sap.sailing.domain.persistence.media.impl;
|
||||
|
||||
import com.mongodb.DB;
|
||||
import com.sap.sailing.domain.persistence.media.MediaObjectFactory;
|
||||
|
||||
public class MediaObjectFactoryImpl implements MediaObjectFactory {
|
||||
|
||||
// private static final Logger logger = Logger.getLogger(MediaObjectFactoryImpl.class.getName());
|
||||
|
||||
// private final DB database;
|
||||
|
||||
public MediaObjectFactoryImpl(DB db) {
|
||||
super();
|
||||
// this.database = db;
|
||||
}
|
||||
|
||||
}
|
||||
-39
@@ -1,39 +0,0 @@
|
||||
package com.sap.sailing.domain.persistence.media.impl;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
|
||||
public class MongoUtils {
|
||||
/**
|
||||
* Key names in MongoDB must not start with a $ sign and must not contain a "." character. This method escapes
|
||||
* those. {@link #unescapeDollarAndDot} is the inverse function.
|
||||
*
|
||||
* @param key
|
||||
* a non-<code>null</code> string which may have length 0
|
||||
* @return a string that can be used as a key in a MongoDB key-value pair and that can be decoded again using
|
||||
* {@link #unescapeDollarAndDot(String)}.
|
||||
*/
|
||||
public static String escapeDollarAndDot(String key) {
|
||||
String result = key.replace("%", "%25").replace("+", "%2B");
|
||||
if (result.length() > 0 && result.charAt(0) == '$') {
|
||||
result = "%24"+result.substring(1);
|
||||
}
|
||||
return result.replace(".", "%2E");
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #escapeDollarAndDot(String)
|
||||
* @param key
|
||||
* a non-<code>null</code> string which may have length 0 and that was returned by
|
||||
* {@link #escapeDollarAndDot(String)}.
|
||||
* @return the string originally passed to {@link #escapeDollarAndDot(String)}
|
||||
*/
|
||||
public static String unescapeDollarAndDot(String escapedKey) {
|
||||
try {
|
||||
return URLDecoder.decode(escapedKey, "UTF-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException("How come this VM doesn't know UTF-8?");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -15,7 +15,8 @@ Require-Bundle: com.sap.sailing.domain,
|
||||
com.sap.sailing.domain.common,
|
||||
com.sap.sailing.domain.persistence,
|
||||
com.sap.sailing.domain.tractracadapter,
|
||||
com.sap.sailing.domain.swisstimingadapter.persistence;bundle-version="1.0.0"
|
||||
com.sap.sailing.domain.swisstimingadapter.persistence;bundle-version="1.0.0",
|
||||
org.hamcrest.core;bundle-version="1.1.0"
|
||||
Bundle-ClassPath: resources/,
|
||||
.
|
||||
Import-Package: com.sap.sailing.server,
|
||||
|
||||
+75
@@ -0,0 +1,75 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.impl;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.swisstimingadapter.RaceType;
|
||||
import com.sap.sailing.domain.swisstimingadapter.RaceType.OlympicRaceCode;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import static org.hamcrest.core.Is.*;
|
||||
import static org.hamcrest.core.IsNull.*;
|
||||
|
||||
public class DomainFactoryTest {
|
||||
|
||||
private com.sap.sailing.domain.swisstimingadapter.impl.DomainFactoryImpl swissTimingDomainFactory;
|
||||
|
||||
@Before
|
||||
public void before() {
|
||||
com.sap.sailing.domain.base.DomainFactory baseDomainFactory = new com.sap.sailing.domain.base.impl.DomainFactoryImpl();
|
||||
swissTimingDomainFactory = new com.sap.sailing.domain.swisstimingadapter.impl.DomainFactoryImpl(
|
||||
baseDomainFactory);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFinnBoatClass() throws Exception {
|
||||
String raceID = "SAM002";
|
||||
RaceType raceType = swissTimingDomainFactory.getRaceTypeFromRaceID(raceID );
|
||||
assertThat(raceType, is(notNullValue()));
|
||||
assertThat(raceType.getRaceCode(), is(OlympicRaceCode.FINN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetFinnBoatClass_LowerCase() throws Exception {
|
||||
String raceID = "sam002";
|
||||
RaceType raceType = swissTimingDomainFactory.getRaceTypeFromRaceID(raceID );
|
||||
assertThat(raceType, is(notNullValue()));
|
||||
assertThat(raceType.getRaceCode(), is(OlympicRaceCode.FINN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet470WomenBoatClass() throws Exception {
|
||||
String raceID = "SAW005";
|
||||
RaceType raceType = swissTimingDomainFactory.getRaceTypeFromRaceID(raceID );
|
||||
assertThat(raceType, is(notNullValue()));
|
||||
assertThat(raceType.getRaceCode(), is(OlympicRaceCode._470_WOMEN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGet470WomenBoatClass2() throws Exception {
|
||||
String raceID = "SAW005_xxx";
|
||||
RaceType raceType = swissTimingDomainFactory.getRaceTypeFromRaceID(raceID );
|
||||
assertThat(raceType, is(notNullValue()));
|
||||
assertThat(raceType.getRaceCode(), is(OlympicRaceCode._470_WOMEN));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDontGetWrongBoatClass() throws Exception {
|
||||
String raceID = "ABC";
|
||||
RaceType raceType = swissTimingDomainFactory.getRaceTypeFromRaceID(raceID );
|
||||
assertThat(raceType, is(notNullValue()));
|
||||
assertThat(raceType.getRaceCode(), is(OlympicRaceCode.UNKNOWN));
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void testCompetitorLookup() throws Exception {
|
||||
before();
|
||||
|
||||
// swissTimingDomainFactory.getOrCreateCompetitor(boatID, threeLetterIOCCode, name, boatClass);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
+7
-6
@@ -1,10 +1,5 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -35,6 +30,7 @@ import com.sap.sailing.domain.base.Regatta;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.common.TrackedRaceStatusEnum;
|
||||
import com.sap.sailing.domain.common.impl.Util;
|
||||
import com.sap.sailing.domain.persistence.media.MediaDB;
|
||||
import com.sap.sailing.domain.racelog.impl.EmptyRaceLogStore;
|
||||
import com.sap.sailing.domain.swisstimingadapter.MessageType;
|
||||
import com.sap.sailing.domain.swisstimingadapter.SailMasterConnector;
|
||||
@@ -59,6 +55,11 @@ import com.sap.sailing.mongodb.MongoDBService;
|
||||
import com.sap.sailing.server.RacingEventService;
|
||||
import com.sap.sailing.server.impl.RacingEventServiceImpl;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class EndToEndListeningStoreAndFowardTest {
|
||||
private static final Logger logger = Logger.getLogger(EndToEndListeningStoreAndFowardTest.class.getName());
|
||||
|
||||
@@ -117,7 +118,7 @@ public class EndToEndListeningStoreAndFowardTest {
|
||||
final com.sap.sailing.domain.base.impl.DomainFactoryImpl baseDomainFactory = new com.sap.sailing.domain.base.impl.DomainFactoryImpl();
|
||||
racingEventService = new RacingEventServiceImpl(mongoDBService, SwissTimingFactory.INSTANCE,
|
||||
new DomainFactoryImpl(baseDomainFactory),
|
||||
new com.sap.sailing.domain.tractracadapter.impl.DomainFactoryImpl(baseDomainFactory));
|
||||
new com.sap.sailing.domain.tractracadapter.impl.DomainFactoryImpl(baseDomainFactory), MediaDB.TEST_STUB);
|
||||
raceHandles = new ArrayList<RacesHandle>();
|
||||
}
|
||||
|
||||
|
||||
+8
-7
@@ -2,8 +2,6 @@ package com.sap.sailing.domain.swisstimingadapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
@@ -31,18 +29,20 @@ public interface DomainFactory {
|
||||
|
||||
Nationality getOrCreateNationality(String threeLetterIOCCode);
|
||||
|
||||
Competitor getOrCreateCompetitor(com.sap.sailing.domain.swisstimingadapter.Competitor competitor, BoatClass boatClass);
|
||||
Competitor getOrCreateCompetitor(com.sap.sailing.domain.swisstimingadapter.Competitor competitor, RaceType raceType);
|
||||
|
||||
Competitor getOrCreateCompetitor(String boatID, String threeLetterIOCCode, String name, BoatClass boatClass);
|
||||
Competitor getOrCreateCompetitor(String boatID, String threeLetterIOCCode, String name, RaceType raceType);
|
||||
|
||||
Competitor getCompetitorByBoatIDAndRaceType(String boatID, RaceType raceType);
|
||||
|
||||
Competitor getCompetitorByBoatIDAndRaceID(String boatID, String raceID);
|
||||
|
||||
RaceDefinition createRaceDefinition(Regatta regatta, Race race, StartList startList, com.sap.sailing.domain.swisstimingadapter.Course course);
|
||||
|
||||
com.sap.sailing.domain.base.Mark getOrCreateMark(String trackerID);
|
||||
|
||||
GPSFixMoving createGPSFix(TimePoint timePointOfTransmission, Fix fix);
|
||||
|
||||
Competitor getCompetitorByBoatIDAndBoatClass(String boatID, BoatClass boatClass);
|
||||
|
||||
void updateCourseWaypoints(Course courseToUpdate, Iterable<Mark> marks) throws PatchFailedException;
|
||||
|
||||
MarkPassing createMarkPassing(TimePoint timePoint, Waypoint waypoint, Competitor competitor);
|
||||
@@ -54,10 +54,11 @@ public interface DomainFactory {
|
||||
SwissTimingFactory swissTimingFactory, DomainFactory domainFactory, RaceLogStore raceLogStore, WindStore windStore,
|
||||
RaceSpecificMessageLoader messageLoader);
|
||||
|
||||
BoatClass getOrCreateBoatClassFromRaceID(String raceID);
|
||||
RaceType getRaceTypeFromRaceID(String raceID);
|
||||
|
||||
ControlPoint getOrCreateControlPoint(Iterable<String> devices);
|
||||
|
||||
RaceDefinition createRaceDefinition(Regatta regatta, String raceID, Iterable<Competitor> competitors,
|
||||
List<ControlPoint> courseDefinition);
|
||||
|
||||
}
|
||||
+61
@@ -0,0 +1,61 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
|
||||
|
||||
public interface RaceType {
|
||||
|
||||
public enum OlympicRaceCode {
|
||||
|
||||
// SAM102000 Men's Windsurfer = Windsufer M�nner RS:X
|
||||
// SAW102000 Women's Windsurfer = Windsurfer Damen RS:X
|
||||
// SAM004000 Men's One Person Dinghy = Laser M�nner
|
||||
// SAW103000 Women's One Person Dinghy = Laser Damen Laser Radial
|
||||
// SAM002000 Men's One Person Dinghy Heavy = Finn Dinghy M�nner
|
||||
// SAM005000 Men's Two Person Dinghy = 470er M�nner
|
||||
// SAW005000 Women's Two Person Dinghy = 470er Damen
|
||||
// SAM009000 Men's Skiff = 49er M�nner
|
||||
// SAM007000 Men's Keelboat = Starboot M�nner
|
||||
// SAW010000 Women's Match Racing = Matchrace Damen Elliott 6M (modified)
|
||||
|
||||
|
||||
UNKNOWN("Unspecified", "Unspecified", Gender.unspecified),
|
||||
FINN("SAM002", "Finn", Gender.male),
|
||||
LASER("SAM004", "Laser", Gender.male),
|
||||
_470_WOMEN("SAW005", "470", Gender.female),
|
||||
_470_MEN("SAM005", "470", Gender.male),
|
||||
STAR("SAM007", "Star", Gender.male),
|
||||
_49ER("SAM009", "49er", Gender.male),
|
||||
ELLIOTT6M("SAW007", "Elliott 6M", Gender.female),
|
||||
RSX_WOMEN("SAW102", "RS:X", Gender.female),
|
||||
RSX_MEN("SAM102", "RS:X", Gender.male),
|
||||
LASER_RADIAL("SAW103", "Laser Radial", Gender.female),
|
||||
_49ERFX_TODO("xxxxx_TODO_xxxxx", "49er FX", Gender.female),
|
||||
NACRA17_TOTO("xxxxx_TODO_xxxxx", "Nacra 17", Gender.mixed);
|
||||
|
||||
enum Gender {
|
||||
male, female, mixed, unspecified;
|
||||
}
|
||||
|
||||
public final String swissTimingCode;
|
||||
|
||||
public final String boatClassName;
|
||||
|
||||
public final Gender gender;
|
||||
|
||||
public final boolean typicallyStartsUpwind;
|
||||
|
||||
private OlympicRaceCode(String swissTimingCode, String boatClassName, Gender gender) {
|
||||
this.swissTimingCode = swissTimingCode;
|
||||
this.boatClassName = boatClassName;
|
||||
this.gender = gender;
|
||||
this.typicallyStartsUpwind = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
OlympicRaceCode getRaceCode();
|
||||
|
||||
BoatClass getBoatClass();
|
||||
|
||||
}
|
||||
+4
@@ -34,4 +34,8 @@ public class CompetitorImpl implements Competitor {
|
||||
return name+"/"+boatID;
|
||||
}
|
||||
|
||||
public String getID() {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+52
-64
@@ -42,6 +42,8 @@ import com.sap.sailing.domain.swisstimingadapter.MessageType;
|
||||
import com.sap.sailing.domain.swisstimingadapter.Race;
|
||||
import com.sap.sailing.domain.swisstimingadapter.RaceSpecificMessageLoader;
|
||||
import com.sap.sailing.domain.swisstimingadapter.StartList;
|
||||
import com.sap.sailing.domain.swisstimingadapter.RaceType;
|
||||
import com.sap.sailing.domain.swisstimingadapter.RaceType.OlympicRaceCode;
|
||||
import com.sap.sailing.domain.swisstimingadapter.SwissTimingFactory;
|
||||
import com.sap.sailing.domain.tracking.GPSFixMoving;
|
||||
import com.sap.sailing.domain.tracking.MarkPassing;
|
||||
@@ -64,36 +66,23 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
private final static Logger logger = Logger.getLogger(DomainFactoryImpl.class.getName());
|
||||
private final Map<String, Regatta> raceIDToRegattaCache;
|
||||
private final Map<Iterable<String>, ControlPoint> controlPointCache;
|
||||
private final Map<String, BoatClass> olympicClassesByID;
|
||||
private final BoatClass unknownBoatClass;
|
||||
private final Map<String, RaceType> raceTypeByID;
|
||||
private final RaceType unknownRaceType;
|
||||
private final com.sap.sailing.domain.base.DomainFactory baseDomainFactory;
|
||||
|
||||
public DomainFactoryImpl(com.sap.sailing.domain.base.DomainFactory baseDomainFactory) {
|
||||
this.baseDomainFactory = baseDomainFactory;
|
||||
raceIDToRegattaCache = new HashMap<String, Regatta>();
|
||||
controlPointCache = new HashMap<Iterable<String>, ControlPoint>();
|
||||
olympicClassesByID = new HashMap<String, BoatClass>();
|
||||
/*
|
||||
SAM102000 Men's Windsurfer = Windsufer M�nner RS:X
|
||||
SAW102000 Women's Windsurfer = Windsurfer Damen RS:X
|
||||
SAM004000 Men's One Person Dinghy = Laser M�nner
|
||||
SAW103000 Women's One Person Dinghy = Laser Damen Laser Radial
|
||||
SAM002000 Men's One Person Dinghy Heavy = Finn Dinghy M�nner
|
||||
SAM005000 Men's Two Person Dinghy = 470er M�nner
|
||||
SAW005000 Women's Two Person Dinghy = 470er Damen
|
||||
SAM009000 Men's Skiff = 49er M�nner
|
||||
SAM007000 Men's Keelboat = Starboot M�nner
|
||||
SAW010000 Women's Match Racing = Matchrace Damen Elliott 6M (modified)
|
||||
*/
|
||||
olympicClassesByID.put("102", baseDomainFactory.getOrCreateBoatClass("RS:X", /* typicallyStartsUpwind */ true));
|
||||
olympicClassesByID.put("004", baseDomainFactory.getOrCreateBoatClass("Laser", /* typicallyStartsUpwind */ true));
|
||||
olympicClassesByID.put("103", baseDomainFactory.getOrCreateBoatClass("Laser Radial", /* typicallyStartsUpwind */ true));
|
||||
olympicClassesByID.put("002", baseDomainFactory.getOrCreateBoatClass("Finn", /* typicallyStartsUpwind */ true));
|
||||
olympicClassesByID.put("005", baseDomainFactory.getOrCreateBoatClass("470", /* typicallyStartsUpwind */ true));
|
||||
olympicClassesByID.put("009", baseDomainFactory.getOrCreateBoatClass("49er", /* alwaysStartsUpwind */ true));
|
||||
olympicClassesByID.put("007", baseDomainFactory.getOrCreateBoatClass("Star", /* typicallyStartsUpwind */ true));
|
||||
olympicClassesByID.put("010", baseDomainFactory.getOrCreateBoatClass("Elliott 6M", /* typicallyStartsUpwind */ true));
|
||||
unknownBoatClass = baseDomainFactory.getOrCreateBoatClass("Unknown", /* typicallyStartsUpwind */ true);
|
||||
raceTypeByID = new HashMap<String, RaceType>();
|
||||
|
||||
for (OlympicRaceCode olympicRaceCode : OlympicRaceCode.values()) {
|
||||
raceTypeByID.put(
|
||||
olympicRaceCode.swissTimingCode,
|
||||
new RaceTypeImpl(olympicRaceCode, baseDomainFactory.getOrCreateBoatClass(
|
||||
olympicRaceCode.boatClassName, olympicRaceCode.typicallyStartsUpwind)));
|
||||
}
|
||||
unknownRaceType = new RaceTypeImpl(OlympicRaceCode.UNKNOWN, baseDomainFactory.getOrCreateBoatClass("Unknown", OlympicRaceCode.UNKNOWN.typicallyStartsUpwind));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -108,7 +97,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
result = raceIDToRegattaCache.get(raceID);
|
||||
}
|
||||
if (result == null) {
|
||||
result = new RegattaImpl(raceLogStore, raceID, getOrCreateBoatClassFromRaceID(raceID), trackedRegattaRegistry,
|
||||
result = new RegattaImpl(raceLogStore, raceID, getRaceTypeFromRaceID(raceID).getBoatClass(), trackedRegattaRegistry,
|
||||
getBaseDomainFactory().createScoringScheme(ScoringSchemeType.LOW_POINT), raceID, null);
|
||||
logger.info("Created regatta "+result.getName()+" ("+result.hashCode()+")");
|
||||
raceIDToRegattaCache.put(raceID, result);
|
||||
@@ -117,26 +106,36 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor getCompetitorByBoatIDAndBoatClass(String boatID, BoatClass boatClass) {
|
||||
return baseDomainFactory.getExistingCompetitorById(getCompetitorID(boatID, boatClass));
|
||||
public Competitor getCompetitorByBoatIDAndRaceType(String boatID, RaceType raceType) {
|
||||
return baseDomainFactory.getExistingCompetitorById(getCompetitorID(boatID, raceType));
|
||||
}
|
||||
|
||||
private String getCompetitorID(String boatID, BoatClass boatClass) {
|
||||
return boatID + "/" + boatClass.getName();
|
||||
@Override
|
||||
public Competitor getCompetitorByBoatIDAndRaceID(String boatID, String raceID) {
|
||||
RaceType raceType = getRaceTypeFromRaceID(raceID);
|
||||
if (raceType != null) {
|
||||
return getCompetitorByBoatIDAndRaceType(boatID, raceType);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private String getCompetitorID(String boatID, RaceType raceType) {
|
||||
return boatID + "/" + raceType.getRaceCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Competitor getOrCreateCompetitor(com.sap.sailing.domain.swisstimingadapter.Competitor competitor, BoatClass boatClass) {
|
||||
Competitor result = getCompetitorByBoatIDAndBoatClass(competitor.getBoatID(), boatClass);
|
||||
public Competitor getOrCreateCompetitor(com.sap.sailing.domain.swisstimingadapter.Competitor competitor, RaceType raceType) {
|
||||
Competitor result = getCompetitorByBoatIDAndRaceType(competitor.getBoatID(), raceType);
|
||||
if (result == null) {
|
||||
Boat boat = new BoatImpl(competitor.getName(), boatClass, competitor.getBoatID());
|
||||
Boat boat = new BoatImpl(competitor.getName(), raceType.getBoatClass(), competitor.getBoatID());
|
||||
List<Person> teamMembers = new ArrayList<Person>();
|
||||
for (String teamMemberName : competitor.getName().split("[-+&]")) {
|
||||
teamMembers.add(new PersonImpl(teamMemberName.trim(), getOrCreateNationality(competitor.getThreeLetterIOCCode()),
|
||||
/* dateOfBirth */ null, teamMemberName.trim()));
|
||||
}
|
||||
Team team = new TeamImpl(competitor.getName(), teamMembers, /* coach */ null);
|
||||
result = baseDomainFactory.getOrCreateCompetitor(getCompetitorID(competitor.getBoatID(), boatClass),
|
||||
result = baseDomainFactory.getOrCreateCompetitor(getCompetitorID(competitor.getBoatID(), raceType),
|
||||
competitor.getName(), team, boat);
|
||||
}
|
||||
return result;
|
||||
@@ -144,8 +143,8 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
|
||||
@Override
|
||||
public Competitor getOrCreateCompetitor(String boatID, String threeLetterIOCCode, String name,
|
||||
BoatClass boatClass) {
|
||||
return getOrCreateCompetitor(new CompetitorImpl(boatID, threeLetterIOCCode, name), boatClass);
|
||||
RaceType raceType) {
|
||||
return getOrCreateCompetitor(new CompetitorImpl(boatID, threeLetterIOCCode, name), raceType);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -157,7 +156,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
waypoints.add(waypoint);
|
||||
}
|
||||
com.sap.sailing.domain.base.Course domainCourse = new CourseImpl("Course", waypoints);
|
||||
BoatClass boatClass = getOrCreateBoatClassFromRaceID(raceID);
|
||||
BoatClass boatClass = getRaceTypeFromRaceID(raceID).getBoatClass();
|
||||
logger.info("Creating RaceDefinitionImpl for race "+raceID);
|
||||
RaceDefinition result = new RaceDefinitionImpl(regatta.getId().toString()+"/"+raceID, domainCourse, boatClass, competitors);
|
||||
regatta.addRace(result);
|
||||
@@ -167,47 +166,36 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
@Override
|
||||
public RaceDefinition createRaceDefinition(Regatta regatta, Race race, StartList startList, Course course) {
|
||||
com.sap.sailing.domain.base.Course domainCourse = createCourse(race.getDescription(), course);
|
||||
BoatClass boatClass = getOrCreateBoatClassFromRaceID(race.getRaceID());
|
||||
Iterable<Competitor> competitors = createCompetitorList(startList, boatClass);
|
||||
RaceType raceType = getRaceTypeFromRaceID(race.getRaceID());
|
||||
Iterable<Competitor> competitors = createCompetitorList(startList, raceType);
|
||||
logger.info("Creating RaceDefinitionImpl for race "+race.getRaceID());
|
||||
RaceDefinition result = new RaceDefinitionImpl(race.getRaceID(), domainCourse,
|
||||
boatClass, competitors);
|
||||
raceType.getBoatClass(), competitors);
|
||||
regatta.addRace(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the SwissTiming olympic race type or race type "UNKNOWN" when no corresponding olympic race type can be found.
|
||||
* Will never return null neither throw a content-related exception.
|
||||
*/
|
||||
@Override
|
||||
public BoatClass getOrCreateBoatClassFromRaceID(String raceID) {
|
||||
BoatClass result;
|
||||
/*
|
||||
SAM102000 Men's Windsurfer = Windsurfer Maenner RS:X
|
||||
SAW102000 Women's Windsurfer = Windsurfer Damen RS:X
|
||||
SAM004000 Men's One Person Dinghy = Laser Maenner
|
||||
SAW103000 Women's One Person Dinghy = Laser Damen Laser Radial
|
||||
SAM002000 Men's One Person Dinghy Heavy = Finn Dinghy Maenner
|
||||
SAM005000 Men's Two Person Dinghy = 470er Maenner
|
||||
SAW005000 Women's Two Person Dinghy = 470er Damen
|
||||
SAM009000 Men's Skiff = 49er Maenner
|
||||
SAM007000 Men's Keelboat = Starboot Maenner
|
||||
SAW010000 Women's Match Racing = Matchrace Damen Elliott 6M (modified)
|
||||
*/
|
||||
if (raceID.toUpperCase().startsWith("SA") && raceID.length() == 9) {
|
||||
String classID = raceID.substring(3, 6);
|
||||
result = olympicClassesByID.get(classID);
|
||||
if (result == null) {
|
||||
// unknown code
|
||||
result = unknownBoatClass;
|
||||
public RaceType getRaceTypeFromRaceID(String raceID) {
|
||||
if (raceID != null && raceID.length() >= 6) {
|
||||
String swissTimingRaceCode = raceID.substring(0, 6).toUpperCase();
|
||||
RaceType result = raceTypeByID.get(swissTimingRaceCode);
|
||||
if (result != null) {
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
result = unknownBoatClass;
|
||||
}
|
||||
return result;
|
||||
//else
|
||||
return unknownRaceType;
|
||||
}
|
||||
|
||||
private Iterable<Competitor> createCompetitorList(StartList startList, BoatClass boatClass) {
|
||||
private Iterable<Competitor> createCompetitorList(StartList startList, RaceType raceType) {
|
||||
List<Competitor> result = new ArrayList<Competitor>();
|
||||
for (com.sap.sailing.domain.swisstimingadapter.Competitor swissTimingCompetitor : startList.getCompetitors()) {
|
||||
Competitor domainCompetitor = getOrCreateCompetitor(swissTimingCompetitor, boatClass);
|
||||
Competitor domainCompetitor = getOrCreateCompetitor(swissTimingCompetitor, raceType);
|
||||
result.add(domainCompetitor);
|
||||
}
|
||||
return result;
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
package com.sap.sailing.domain.swisstimingadapter.impl;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.swisstimingadapter.RaceType;
|
||||
|
||||
public class RaceTypeImpl implements RaceType {
|
||||
|
||||
private final OlympicRaceCode raceCode;
|
||||
private final BoatClass boatClass;
|
||||
|
||||
public RaceTypeImpl(OlympicRaceCode raceCode, BoatClass boatClass) {
|
||||
this.raceCode = raceCode;
|
||||
this.boatClass = boatClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final OlympicRaceCode getRaceCode() {
|
||||
return raceCode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BoatClass getBoatClass() {
|
||||
return boatClass;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-7
@@ -13,7 +13,6 @@ import java.util.TreeMap;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.RaceDefinition;
|
||||
@@ -232,8 +231,8 @@ public class SwissTimingRaceTrackerImpl extends AbstractRaceTrackerImpl implemen
|
||||
trackedRace.recordFix(mark, gpsFix);
|
||||
break;
|
||||
case COMPETITOR:
|
||||
Competitor competitor = domainFactory.getCompetitorByBoatIDAndBoatClass(
|
||||
fix.getBoatID(), domainFactory.getOrCreateBoatClassFromRaceID(raceID));
|
||||
Competitor competitor = domainFactory.getCompetitorByBoatIDAndRaceID(
|
||||
fix.getBoatID(), raceID);
|
||||
DynamicGPSFixTrack<Competitor, GPSFixMoving> competitorTrack = trackedRace.getTrack(competitor);
|
||||
competitorTrack.addGPSFix(gpsFix);
|
||||
break;
|
||||
@@ -258,9 +257,8 @@ public class SwissTimingRaceTrackerImpl extends AbstractRaceTrackerImpl implemen
|
||||
List<Triple<Integer, Integer, Long>> markIndicesRanksAndTimesSinceStartInMilliseconds) {
|
||||
assert this.raceID.equals(raceID);
|
||||
if (isTrackedRaceStillReachable()) {
|
||||
final BoatClass boatClass = domainFactory.getOrCreateBoatClassFromRaceID(raceID);
|
||||
Competitor competitor = domainFactory.getCompetitorByBoatIDAndBoatClass(boatID,
|
||||
boatClass);
|
||||
Competitor competitor = domainFactory.getCompetitorByBoatIDAndRaceID(boatID,
|
||||
raceID);
|
||||
// the list of mark indices and time stamps is partial and usually only shows the last mark passing;
|
||||
// we need to use this to *update* the competitor's mark passings list, not *replace* it
|
||||
TreeMap<Integer, MarkPassing> markPassingsByMarkIndex = new TreeMap<Integer, MarkPassing>();
|
||||
@@ -288,7 +286,7 @@ public class SwissTimingRaceTrackerImpl extends AbstractRaceTrackerImpl implemen
|
||||
MillisecondsTimePoint timePoint = new MillisecondsTimePoint(
|
||||
startTime.asMillis() + markIndexRankAndTimeSinceStartInMilliseconds.getC());
|
||||
MarkPassing markPassing = domainFactory.createMarkPassing(timePoint, waypoint,
|
||||
domainFactory.getCompetitorByBoatIDAndBoatClass(boatID, boatClass));
|
||||
domainFactory.getCompetitorByBoatIDAndRaceID(boatID, raceID));
|
||||
markPassingsByMarkIndex.put(markIndexRankAndTimeSinceStartInMilliseconds.getA(), markPassing);
|
||||
} else {
|
||||
//
|
||||
|
||||
+2
-2
@@ -101,8 +101,8 @@ public class TMDMessageQueue {
|
||||
// otherwise, this could lead to the "guessed time" to
|
||||
while (i.hasNext()) {
|
||||
TMDMessageContents messageContents = i.next();
|
||||
Competitor competitor = raceTracker.getDomainFactory().getCompetitorByBoatIDAndBoatClass(messageContents.getBoatID(),
|
||||
trackedRace.getRace().getBoatClass());
|
||||
Competitor competitor = raceTracker.getDomainFactory().getCompetitorByBoatIDAndRaceID(messageContents.getBoatID(),
|
||||
messageContents.getRaceID());
|
||||
NavigableSet<MarkPassing> oldMarkPassings = trackedRace.getMarkPassings(competitor);
|
||||
TreeMap<Integer, MarkPassing> cleansedMarkPassingsForCompetitor = cleansedMarkPassings.get(competitor);
|
||||
if (cleansedMarkPassingsForCompetitor == null) {
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
+22
-4
@@ -211,7 +211,8 @@ public class SwissTimingReplayAdapterServiceTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void printRaceData_SAM009903_20120731_sapsailing_replay() throws Exception {
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAM009903.20120731_sapsailing.replay"),
|
||||
new SwissTimingReplayParserImpl().readData(
|
||||
getClass().getResourceAsStream("/SAM009903.20120731_sapsailing.replay"),
|
||||
new SwissTimingReplayPrintListener());
|
||||
}
|
||||
|
||||
@@ -225,19 +226,36 @@ public class SwissTimingReplayAdapterServiceTest {
|
||||
@Test
|
||||
@Ignore
|
||||
public void printReadRaceData_SAW010955_20120802() throws Exception {
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAW010955.20120802.replay"), new SwissTimingReplayPrintListener());
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAW010955.20120802.replay"),
|
||||
new SwissTimingReplayPrintListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void printReadRaceData_SAM002901() throws Exception {
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAM002901.replay"), new SwissTimingReplayPrintListener());
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAM002901.replay"),
|
||||
new SwissTimingReplayPrintListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void printReadRaceData_SAM009904_20120731() throws Exception {
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAM009904.20120731.replay"), new SwissTimingReplayPrintListener());
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAM009904.20120731.replay"),
|
||||
new SwissTimingReplayPrintListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void printRaceData_SAW102101_20120807() throws Exception {
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAW102101.20120807.replay"),
|
||||
new SwissTimingReplayPrintListener());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void printRaceData_SAM102101_20120807() throws Exception {
|
||||
new SwissTimingReplayParserImpl().readData(getClass().getResourceAsStream("/SAM102101.20120807.replay"),
|
||||
new SwissTimingReplayPrintListener());
|
||||
}
|
||||
|
||||
}
|
||||
+5
-6
@@ -15,7 +15,6 @@ import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import com.sap.sailing.domain.base.BoatClass;
|
||||
import com.sap.sailing.domain.base.Competitor;
|
||||
import com.sap.sailing.domain.base.ControlPoint;
|
||||
import com.sap.sailing.domain.base.Course;
|
||||
@@ -39,6 +38,7 @@ import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
import com.sap.sailing.domain.common.impl.WindSourceWithAdditionalID;
|
||||
import com.sap.sailing.domain.racelog.impl.EmptyRaceLogStore;
|
||||
import com.sap.sailing.domain.swisstimingadapter.DomainFactory;
|
||||
import com.sap.sailing.domain.swisstimingadapter.RaceType;
|
||||
import com.sap.sailing.domain.swisstimingreplayadapter.CompetitorStatus;
|
||||
import com.sap.sailing.domain.swisstimingreplayadapter.SwissTimingReplayListener;
|
||||
import com.sap.sailing.domain.swisstimingreplayadapter.SwissTimingReplayParser;
|
||||
@@ -83,6 +83,8 @@ public class SwissTimingReplayToDomainAdapter extends SwissTimingReplayAdapter {
|
||||
*/
|
||||
private String currentRaceID;
|
||||
|
||||
private RaceType currentRaceType;
|
||||
|
||||
/**
|
||||
* Reference time point for time specifications
|
||||
*/
|
||||
@@ -158,10 +160,6 @@ public class SwissTimingReplayToDomainAdapter extends SwissTimingReplayAdapter {
|
||||
return trackedRacePerRaceID.values();
|
||||
}
|
||||
|
||||
private BoatClass getCurrentBoatClass() {
|
||||
return domainFactory.getOrCreateBoatClassFromRaceID(currentRaceID);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void referenceTimestamp(long referenceTimestampMillis) {
|
||||
referenceTimePoint = new MillisecondsTimePoint(referenceTimestampMillis);
|
||||
@@ -175,6 +173,7 @@ public class SwissTimingReplayToDomainAdapter extends SwissTimingReplayAdapter {
|
||||
@Override
|
||||
public void raceID(String raceID) {
|
||||
currentRaceID = raceID;
|
||||
currentRaceType = domainFactory.getRaceTypeFromRaceID(currentRaceID);
|
||||
}
|
||||
|
||||
private boolean isValid(int threeByteValue) {
|
||||
@@ -236,7 +235,7 @@ public class SwissTimingReplayToDomainAdapter extends SwissTimingReplayAdapter {
|
||||
short ctPoints_x10_Winner) {
|
||||
if (boatType == BoatType.Competitor) {
|
||||
Competitor competitor = domainFactory.getOrCreateCompetitor(sailNumberOrTrackerID, threeLetterIOCCode.trim(), name.trim(),
|
||||
getCurrentBoatClass());
|
||||
currentRaceType);
|
||||
Set<Competitor> competitorsOfCurrentRace = competitorsPerRaceID.get(currentRaceID);
|
||||
if (competitorsOfCurrentRace == null) {
|
||||
competitorsOfCurrentRace = new HashSet<>();
|
||||
|
||||
Binary file not shown.
+133
@@ -0,0 +1,133 @@
|
||||
package com.sap.sailing.domain.common;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.media.MediaTrack;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class MediaTrackTest {
|
||||
|
||||
@Test
|
||||
public void testExactOverlap() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 1;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime());
|
||||
Date endTime = new Date(mediaTrack.deriveEndTime().getTime());
|
||||
assertTrue(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoOverlapLeft() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 1;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() + 2);
|
||||
Date endTime = new Date(startTime.getTime() + 1);
|
||||
assertFalse(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNoOverlapRight() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 1;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() - 2);
|
||||
Date endTime = new Date(startTime.getTime() + 1);
|
||||
assertFalse(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialOverlapLeft() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 2;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() - 1);
|
||||
Date endTime = new Date(startTime.getTime() + 2);
|
||||
assertTrue(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPartialOverlapRight() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 2;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() + 1);
|
||||
Date endTime = new Date(startTime.getTime() + 2);
|
||||
assertTrue(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMediaFullyIncluded() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 1;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() - 1);
|
||||
Date endTime = new Date(startTime.getTime() + 3);
|
||||
assertTrue(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMediaFullyIncluding() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 3;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() + 1);
|
||||
Date endTime = new Date(startTime.getTime() + 1);
|
||||
assertTrue(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverlapOpenEndStartingEarlier() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 1;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() - 1);
|
||||
Date endTime = null; //--> open end
|
||||
assertTrue(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOverlapOpenEndStartingLater() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 2;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() + 1);
|
||||
Date endTime = null; //--> open end
|
||||
assertTrue(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOpenEndNoOverlap() throws Exception {
|
||||
MediaTrack mediaTrack = new MediaTrack();
|
||||
mediaTrack.startTime = new Date();
|
||||
mediaTrack.durationInMillis = 1;
|
||||
|
||||
Date startTime = new Date(mediaTrack.startTime.getTime() + 2);
|
||||
Date endTime = null; //--> open end
|
||||
assertFalse(mediaTrack.overlapsWith(startTime, endTime));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.sap.sailing.domain.common;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.media.MediaUtil;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class MediaUtilTest {
|
||||
|
||||
@Test
|
||||
public void testCompareDatesAllNull() throws Exception {
|
||||
Date date1 = null;
|
||||
Date date2 = null;
|
||||
assertTrue(MediaUtil.compareDatesAllowingNull(date1, date2) == 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareDatesFirstNull() throws Exception {
|
||||
Date date1 = null;
|
||||
Date date2 = new Date();
|
||||
assertTrue(MediaUtil.compareDatesAllowingNull(date1, date2) < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareDatesSecondNull() throws Exception {
|
||||
Date date1 = new Date();
|
||||
Date date2 = null;
|
||||
assertTrue(MediaUtil.compareDatesAllowingNull(date1, date2) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareDatesFirstGreaterSecond() throws Exception {
|
||||
Date date1 = new Date();
|
||||
Date date2 = new Date(date1.getTime() - 1);
|
||||
assertTrue(MediaUtil.compareDatesAllowingNull(date1, date2) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompareDatesSecondGreaterFirst() throws Exception {
|
||||
Date date1 = new Date();
|
||||
Date date2 = new Date(date1.getTime() + 1);
|
||||
assertTrue(MediaUtil.compareDatesAllowingNull(date1, date2) < 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsDatesAllNull() throws Exception {
|
||||
Date date1 = null;
|
||||
Date date2 = null;
|
||||
assertTrue(MediaUtil.equalsDatesAllowingNull(date1, date2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsDatesFirstNull() throws Exception {
|
||||
Date date1 = null;
|
||||
Date date2 = new Date();
|
||||
assertFalse(MediaUtil.equalsDatesAllowingNull(date1, date2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsDatesSecondNull() throws Exception {
|
||||
Date date1 = new Date();
|
||||
Date date2 = null;
|
||||
assertFalse(MediaUtil.equalsDatesAllowingNull(date1, date2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsDatesBothEqual() throws Exception {
|
||||
Date date1 = new Date();
|
||||
Date date2 = new Date(date1.getTime());
|
||||
assertTrue(MediaUtil.equalsDatesAllowingNull(date1, date2));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testEqualsDatesNotEqual() throws Exception {
|
||||
Date date1 = new Date();
|
||||
Date date2 = new Date(date1.getTime() + 1);
|
||||
assertFalse(MediaUtil.equalsDatesAllowingNull(date1, date2));
|
||||
}
|
||||
|
||||
}
|
||||
Executable
+46
@@ -0,0 +1,46 @@
|
||||
package com.sap.sailing.domain.common.test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import com.sap.sailing.domain.common.Speed;
|
||||
import com.sap.sailing.domain.common.impl.MeterPerSecondSpeedImpl;
|
||||
|
||||
public class BeaufortTest {
|
||||
@Test
|
||||
public void testOneBeaufortLow() {
|
||||
Speed speed = new MeterPerSecondSpeedImpl(0.3);
|
||||
assertEquals(1, Math.round(speed.getBeaufort()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testOneBeaufortHigh() {
|
||||
Speed speed = new MeterPerSecondSpeedImpl(1.5);
|
||||
assertEquals(1, Math.round(speed.getBeaufort()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoBeaufortLow() {
|
||||
Speed speed = new MeterPerSecondSpeedImpl(1.6);
|
||||
assertEquals(2, Math.round(speed.getBeaufort()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTwoBeaufortHigh() {
|
||||
Speed speed = new MeterPerSecondSpeedImpl(3.3);
|
||||
assertEquals(2, Math.round(speed.getBeaufort()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTenBeaufortLow() {
|
||||
Speed speed = new MeterPerSecondSpeedImpl(24.5);
|
||||
assertEquals(10, Math.round(speed.getBeaufort()));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTenBeaufortHigh() {
|
||||
Speed speed = new MeterPerSecondSpeedImpl(28.4);
|
||||
assertEquals(10, Math.round(speed.getBeaufort()));
|
||||
}
|
||||
}
|
||||
+272
@@ -0,0 +1,272 @@
|
||||
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.assertNull;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
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.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.impl.Util;
|
||||
import com.sap.sailing.domain.test.StoredTrackBasedTest;
|
||||
import com.sap.sailing.util.ClonerImpl;
|
||||
|
||||
/**
|
||||
* Tests the compressing / de-compressing functionality of {@link LeaderboardDTO} and {@link IncrementalLeaderboardDTO}.
|
||||
* See also bug 1417.<p>
|
||||
*
|
||||
* The data of a meaningful and non-trivial {@link LeaderboardDTO} is obtained by using an instrumented version of
|
||||
* <code>SailingServiceImpl.getLeaderboardByName(...)</code> which serializes the leaderboard at the end of the method
|
||||
* to a file used by this test. The leaderboard that this test wants to use is that of the 505 Worlds 2013, obtained
|
||||
* for an expanded Race R9 at time 2013-05-03T17:21:40Z.
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class LeaderboardDTODiffingTest {
|
||||
private LeaderboardDTO previousVersion;
|
||||
private IncrementalLeaderboardDTO newVersion;
|
||||
private final Cloner cloner = new ClonerImpl();
|
||||
|
||||
@Before
|
||||
public void setUp() throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||
ObjectInputStream ois = StoredTrackBasedTest.getObjectInputStream("IncrementalLeaderboardDTO.ser");
|
||||
previousVersion = (LeaderboardDTO) ois.readObject();
|
||||
ois.close();
|
||||
newVersion = new IncrementalLeaderboardDTO("12345", cloner);
|
||||
cloner.clone(previousVersion, newVersion);
|
||||
}
|
||||
|
||||
private CompetitorDTO getPreviousCompetitorByName(String name) {
|
||||
for (CompetitorDTO competitor : previousVersion.competitors) {
|
||||
if (competitor.getName().equals(name)) {
|
||||
return competitor;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLeaderboardSuccessfullyRead() {
|
||||
assertNotNull(previousVersion);
|
||||
assertNotNull(newVersion);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPreviousAndNewVersionHaveEqualRows() {
|
||||
assertEquals(previousVersion.rows, newVersion.rows);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTotalStripping() {
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
assertNull(newVersion.rows);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMajorStripping() {
|
||||
newVersion.rows = new HashMap<CompetitorDTO, LeaderboardRowDTO>(newVersion.rows);
|
||||
CompetitorDTO wolfgang = getPreviousCompetitorByName("HUNGER +JESS");
|
||||
assertNotNull(wolfgang);
|
||||
LeaderboardRowDTO wolfgangsRow = new LeaderboardRowDTO();
|
||||
cloner.clone(newVersion.rows.get(wolfgang), wolfgangsRow);
|
||||
newVersion.rows.put(wolfgang, wolfgangsRow);
|
||||
wolfgangsRow.totalDistanceTraveledInMeters += 1;
|
||||
Map<CompetitorDTO, LeaderboardRowDTO> rowsBeforeStripping = newVersion.rows;
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
assertNotNull(newVersion.rows);
|
||||
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());
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(rowsBeforeStripping, applied.rows);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStrippingExceptOneColumnInOneRace() {
|
||||
HashMap<CompetitorDTO, LeaderboardRowDTO> newRows = new HashMap<CompetitorDTO, LeaderboardRowDTO>(newVersion.rows);
|
||||
double newDistance = 1234;
|
||||
String nameOfRaceColumnToChange = "R9";
|
||||
int indexOfLegToChange = 7; // ( zero based: ) 8th leg is the last leg
|
||||
for (Map.Entry<CompetitorDTO, LeaderboardRowDTO> e : newVersion.rows.entrySet()) {
|
||||
LeaderboardRowDTO newRow = new LeaderboardRowDTO();
|
||||
cloner.clone(e.getValue(), newRow);
|
||||
newRows.put(e.getKey(), newRow);
|
||||
newRow.fieldsByRaceColumnName = new HashMap<String, LeaderboardEntryDTO>(newRow.fieldsByRaceColumnName); // clone entry map
|
||||
LeaderboardEntryDTO newEntry = new LeaderboardEntryDTO();
|
||||
cloner.clone(newRow.fieldsByRaceColumnName.get(nameOfRaceColumnToChange), newEntry);
|
||||
newRow.fieldsByRaceColumnName.put(nameOfRaceColumnToChange, newEntry);
|
||||
if (newEntry.legDetails != null) {
|
||||
newEntry.legDetails = new ArrayList<LegEntryDTO>(newEntry.legDetails); // clone leg details list
|
||||
if (newEntry.legDetails.get(indexOfLegToChange) != null) {
|
||||
LegEntryDTO newLegDetail = new LegEntryDTO();
|
||||
cloner.clone(newEntry.legDetails.get(indexOfLegToChange), newLegDetail);
|
||||
newEntry.legDetails.set(indexOfLegToChange, newLegDetail);
|
||||
newLegDetail.distanceTraveledInMeters = newDistance;
|
||||
newDistance += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
newVersion.rows = newRows;
|
||||
Map<CompetitorDTO, LeaderboardRowDTO> rowsBeforeStripping = newVersion.rows;
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
assertNotNull(newVersion.rows);
|
||||
assertEquals(previousVersion.rows.size()-17, newVersion.rows.size()); // all rows have changed except for 17 that have no leg details in leg 8
|
||||
// now assert that for all rows there is no leaderboard entry for all races but R9 and
|
||||
// for R9 there either are no leg details or all leg details for all legs other than L8 are null
|
||||
for (Map.Entry<CompetitorDTO, LeaderboardRowDTO> e : newVersion.rows.entrySet()) {
|
||||
if (e.getValue().fieldsByRaceColumnName != null) {
|
||||
assertTrue(e.getValue().fieldsByRaceColumnName.size() <= 1);
|
||||
for (Map.Entry<String, LeaderboardEntryDTO> e2 : e.getValue().fieldsByRaceColumnName.entrySet()) {
|
||||
if (e2.getKey().equals(nameOfRaceColumnToChange)) {
|
||||
List<LegEntryDTO> r9LegDetails = e2.getValue().legDetails;
|
||||
if (r9LegDetails != null) {
|
||||
for (int i=0; i<r9LegDetails.size(); i++) {
|
||||
if (i != indexOfLegToChange) {
|
||||
assertNull(r9LegDetails.get(i));
|
||||
} else {
|
||||
assertNotNull(r9LegDetails.get(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// if there is an entry for any column other than R9 (which is not really expected) then the entry is expected to be null
|
||||
assertNull(e2.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(rowsBeforeStripping, applied.rows);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompetitorListChange() {
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
new BoatClassDTO("505", 5.05));
|
||||
newVersion.competitors.add(13, somebodyNew); // insert a competitor; this should mess up all others' indexes; check if this works
|
||||
CompetitorDTO wolfgang = getPreviousCompetitorByName("HUNGER +JESS");
|
||||
newVersion.competitors.remove(wolfgang);
|
||||
newVersion.rows.remove(wolfgang); // remove another competitor
|
||||
List<CompetitorDTO> newCompetitorsBeforeStripping = new ArrayList<CompetitorDTO>(newVersion.competitors);
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
assertNull(newVersion.competitors); // but there should be an added competitor that we can't see through the public interface
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(newCompetitorsBeforeStripping, applied.competitors);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSuppressionChange() {
|
||||
final List<CompetitorDTO> newSuppressedCompetitors = new ArrayList<CompetitorDTO>();
|
||||
Util.addAll(newVersion.getSuppressedCompetitors(), newSuppressedCompetitors);
|
||||
newVersion.setSuppressedCompetitors(newSuppressedCompetitors);
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
new BoatClassDTO("505", 5.05));
|
||||
newVersion.setSuppressed(newVersion.competitors.get(13), true); // suppress an existing competitor; compaction should reduce this to a single number only
|
||||
newVersion.setSuppressed(somebodyNew, true); // check that mixed mode with existing and new competitors works as well
|
||||
List<CompetitorDTO> newSuppressedCompetitorsBeforeStripping = new ArrayList<CompetitorDTO>();
|
||||
Util.addAll(newVersion.getSuppressedCompetitors(), newSuppressedCompetitorsBeforeStripping);
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
assertEquals(2, Util.size(newVersion.getSuppressedCompetitors()));
|
||||
assertTrue(Util.contains(newVersion.getSuppressedCompetitors(), somebodyNew));
|
||||
for (CompetitorDTO compactSuppressedCompetitor : newVersion.getSuppressedCompetitors()) {
|
||||
if (compactSuppressedCompetitor != somebodyNew) {
|
||||
assertFalse(compactSuppressedCompetitor instanceof CompetitorDTOImpl); // assert that the existing competitor was compacted
|
||||
}
|
||||
}
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(newSuppressedCompetitorsBeforeStripping, applied.getSuppressedCompetitors());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDisplayNameChange() {
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
new BoatClassDTO("505", 5.05));
|
||||
newVersion.competitors.add(somebodyNew);
|
||||
newVersion.competitorDisplayNames = new HashMap<CompetitorDTO, String>(newVersion.competitorDisplayNames);
|
||||
newVersion.competitorDisplayNames.put(newVersion.competitors.get(13), "Humba");
|
||||
newVersion.competitorDisplayNames.put(somebodyNew, "Trala");
|
||||
final HashMap<CompetitorDTO, String> newDisplayNamesBeforeStripping = new HashMap<CompetitorDTO, String>();
|
||||
newDisplayNamesBeforeStripping.putAll(newVersion.competitorDisplayNames);
|
||||
newVersion.strip(previousVersion);
|
||||
assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(newVersion);
|
||||
assertEquals(2, newVersion.competitorDisplayNames.size());
|
||||
assertTrue(newVersion.competitorDisplayNames.keySet().contains(somebodyNew));
|
||||
for (CompetitorDTO compactSuppressedCompetitor : newVersion.competitorDisplayNames.keySet()) {
|
||||
if (compactSuppressedCompetitor != somebodyNew) {
|
||||
assertFalse(compactSuppressedCompetitor instanceof CompetitorDTOImpl); // assert that the existing competitor was compacted
|
||||
}
|
||||
}
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(newDisplayNamesBeforeStripping, applied.competitorDisplayNames);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCompetitorOrderingInRaceChange() {
|
||||
RaceColumnDTO r9 = newVersion.getRaceColumnByName("R9");
|
||||
Map<RaceColumnDTO, List<CompetitorDTO>> newCompetitorOrderingPerRace = new HashMap<RaceColumnDTO, List<CompetitorDTO>>(newVersion.getCompetitorOrderingPerRace());
|
||||
newVersion.setCompetitorOrderingPerRace(newCompetitorOrderingPerRace);
|
||||
List<CompetitorDTO> newOrdering = new ArrayList<CompetitorDTO>(newVersion.getCompetitorsFromBestToWorst(r9));
|
||||
newVersion.setCompetitorsFromBestToWorst(r9, newOrdering);
|
||||
newVersion.competitors = new ArrayList<CompetitorDTO>(newVersion.competitors); // clone competitor list so it's not identical to that of previous version
|
||||
CompetitorDTO somebodyNew = new CompetitorDTOImpl("Someone New", "DE", "GER", "Germany", "GER 1234", "912p09871203987",
|
||||
new BoatClassDTO("505", 5.05));
|
||||
newVersion.competitors.add(somebodyNew);
|
||||
newOrdering.add(somebodyNew);
|
||||
CompetitorDTO formerRank13 = newOrdering.remove(13);
|
||||
newOrdering.add(12, formerRank13);
|
||||
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));
|
||||
}
|
||||
}
|
||||
assertEquals(newVersion.getCompetitorsFromBestToWorst(r9).size()-1, newVersion.getCompetitorsFromBestToWorst(r9).indexOf(somebodyNew));
|
||||
for (CompetitorDTO compactSuppressedCompetitor : newVersion.getCompetitorsFromBestToWorst(r9)) {
|
||||
if (compactSuppressedCompetitor != somebodyNew) {
|
||||
assertFalse(compactSuppressedCompetitor instanceof CompetitorDTOImpl); // assert that the existing competitor was compacted
|
||||
}
|
||||
}
|
||||
LeaderboardDTO applied = newVersion.getLeaderboardDTO(previousVersion);
|
||||
assertEquals(newOrderBeforeStripping, applied.getCompetitorsFromBestToWorst(applied.getRaceColumnByName("R9")));
|
||||
}
|
||||
|
||||
private void assertAllRowsKeysAreIdenticalToAllLeaderboardRowDTOCompetitors(LeaderboardDTO leaderboard) {
|
||||
if (leaderboard.rows != null) {
|
||||
for (Map.Entry<CompetitorDTO, LeaderboardRowDTO> e : leaderboard.rows.entrySet()) {
|
||||
assertSame(e.getKey(), e.getValue().competitor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
package com.sap.sailing.domain.test;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
* See the use of bit shift operations in <code>IncrementalLeaderboardDTO</code>
|
||||
*
|
||||
* @author Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class BitShiftTest {
|
||||
@Test
|
||||
public void bitShiftWithLongTest() {
|
||||
long l = 1l<<63;
|
||||
assertTrue((l & 1l<<63) != 0);
|
||||
}
|
||||
}
|
||||
+4
@@ -70,6 +70,10 @@ public abstract class StoredTrackBasedTest extends TrackBasedTest {
|
||||
+ (competitor.getBoat().getSailID() == null ? "" : "-" + competitor.getBoat().getSailID()));
|
||||
}
|
||||
|
||||
public static ObjectInputStream getObjectInputStream(String fileNameWithinResources) throws FileNotFoundException, IOException {
|
||||
return new ObjectInputStream(new FileInputStream(new File(RESOURCES+fileNameWithinResources)));
|
||||
}
|
||||
|
||||
private Set<String> getCompetitorNamesOfStoredTracks(String regattaName) {
|
||||
Set<String> result = new HashSet<String>();
|
||||
File d = new File(RESOURCES);
|
||||
|
||||
@@ -93,11 +93,9 @@ public interface DomainFactory extends SharedDomainFactory {
|
||||
|
||||
CompetitorDTO convertToCompetitorDTO(Competitor c);
|
||||
|
||||
FleetDTO convertToFleetDTO(Series series, Fleet fleet);
|
||||
FleetDTO convertToFleetDTO(Fleet fleet);
|
||||
|
||||
FleetDTO convertToFleetDTO(RaceColumn raceColumn, Fleet fleet);
|
||||
|
||||
RaceDTO createRaceDTO(TrackedRegattaRegistry trackedRegattaRegistry, boolean b, RegattaAndRaceIdentifier raceIdentifier, TrackedRace trackedRace);
|
||||
RaceDTO createRaceDTO(TrackedRegattaRegistry trackedRegattaRegistry, boolean withGeoLocationData, RegattaAndRaceIdentifier raceIdentifier, TrackedRace trackedRace);
|
||||
|
||||
PlacemarkDTO convertToPlacemarkDTO(Placemark placemark);
|
||||
|
||||
|
||||
+4
-15
@@ -28,9 +28,6 @@ import com.sap.sailing.domain.base.Gate;
|
||||
import com.sap.sailing.domain.base.Mark;
|
||||
import com.sap.sailing.domain.base.Nationality;
|
||||
import com.sap.sailing.domain.base.ObjectInputStreamResolvingAgainstDomainFactory;
|
||||
import com.sap.sailing.domain.base.RaceColumn;
|
||||
import com.sap.sailing.domain.base.RaceColumnInSeries;
|
||||
import com.sap.sailing.domain.base.Series;
|
||||
import com.sap.sailing.domain.base.Team;
|
||||
import com.sap.sailing.domain.base.Waypoint;
|
||||
import com.sap.sailing.domain.common.CountryCode;
|
||||
@@ -45,6 +42,7 @@ import com.sap.sailing.domain.common.TimePoint;
|
||||
import com.sap.sailing.domain.common.WithID;
|
||||
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.PlacemarkDTO;
|
||||
import com.sap.sailing.domain.common.dto.PlacemarkOrderDTO;
|
||||
@@ -336,7 +334,7 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
CompetitorDTO competitorDTO = weakCompetitorDTOCache.get(c);
|
||||
if (competitorDTO == null) {
|
||||
CountryCode countryCode = c.getTeam().getNationality().getCountryCode();
|
||||
competitorDTO = new CompetitorDTO(c.getName(), countryCode == null ? ""
|
||||
competitorDTO = new CompetitorDTOImpl(c.getName(), countryCode == null ? ""
|
||||
: countryCode.getTwoLetterISOCode(),
|
||||
countryCode == null ? "" : countryCode.getThreeLetterIOCCode(), countryCode == null ? ""
|
||||
: countryCode.getName(), c.getBoat().getSailID(), c.getId().toString(),
|
||||
@@ -348,17 +346,8 @@ public class DomainFactoryImpl implements DomainFactory {
|
||||
}
|
||||
|
||||
@Override
|
||||
public FleetDTO convertToFleetDTO(Series series, Fleet fleet) {
|
||||
return new FleetDTO(fleet.getName(), series.getName(), fleet.getOrdering(), fleet.getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
public FleetDTO convertToFleetDTO(RaceColumn raceColumn, Fleet fleet) {
|
||||
String seriesNameOfFleet = null;
|
||||
if (raceColumn instanceof RaceColumnInSeries) {
|
||||
seriesNameOfFleet = ((RaceColumnInSeries) raceColumn).getSeries().getName();
|
||||
}
|
||||
return new FleetDTO(fleet.getName(), seriesNameOfFleet, fleet.getOrdering(), fleet.getColor());
|
||||
public FleetDTO convertToFleetDTO(Fleet fleet) {
|
||||
return new FleetDTO(fleet.getName(), fleet.getOrdering(), fleet.getColor());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+1
-1
@@ -80,7 +80,7 @@ public class LeaderboardDTOCache implements LeaderboardCache {
|
||||
this.leaderboard = leaderboard;
|
||||
this.waitForLatestAnalyses = waitForLatestAnalyses;
|
||||
// if the leaderboard becomes weakly referenced and eventually GCed, then so can the cached results for it
|
||||
this.leaderboardCache = new LinkedHashMap<Pair<TimePoint, Collection<String>>, FutureTask<LeaderboardDTO>>() {
|
||||
this.leaderboardCache = new LinkedHashMap<Pair<TimePoint, Collection<String>>, FutureTask<LeaderboardDTO>>(16, 0.75f, /* access-based eviction */ true) {
|
||||
private static final long serialVersionUID = 7287916997229815039L;
|
||||
@Override
|
||||
protected boolean removeEldestEntry(Map.Entry<Pair<TimePoint, Collection<String>>, FutureTask<LeaderboardDTO>> e) {
|
||||
|
||||
+140
-124
@@ -14,6 +14,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.NavigableSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -326,6 +327,13 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
invalidateCacheAndRemoveThisListenerFromTrackedRace();
|
||||
}
|
||||
}
|
||||
|
||||
private static class UUIDGenerator implements LeaderboardDTO.UUIDGenerator {
|
||||
@Override
|
||||
public String generateRandomUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
}
|
||||
|
||||
public AbstractSimpleLeaderboardImpl(SettableScoreCorrection scoreCorrection, ThresholdBasedResultDiscardingRule resultDiscardingRule) {
|
||||
this.carriedPoints = new HashMap<Competitor, Double>();
|
||||
@@ -978,7 +986,7 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
|
||||
@Override
|
||||
public void raceLogEventAdded(RaceColumn raceColumn, RaceLogIdentifier raceLogIdentifier, RaceLogEvent event) {
|
||||
getRaceColumnListeners().notifyListenersAboutRaceLogEventAdded(raceColumn, raceLogIdentifier, event);
|
||||
getRaceColumnListeners().notifyListenersAboutRaceLogEventAdded(raceColumn, raceLogIdentifier, event);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -988,143 +996,151 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
throws NoWindException {
|
||||
long startOfRequestHandling = System.currentTimeMillis();
|
||||
LeaderboardDTO result = null;
|
||||
result = new LeaderboardDTO(this.getScoreCorrection().getTimePointOfLastCorrectionsValidity()==null ?
|
||||
null : this.getScoreCorrection().getTimePointOfLastCorrectionsValidity().asDate(),
|
||||
this.getScoreCorrection()==null?null:this.getScoreCorrection().getComment(),
|
||||
this.getScoringScheme().isHigherBetter());
|
||||
result.competitors = new ArrayList<CompetitorDTO>();
|
||||
result.name = this.getName();
|
||||
result.competitorDisplayNames = new HashMap<CompetitorDTO, String>();
|
||||
for (Competitor suppressedCompetitor : this.getSuppressedCompetitors()) {
|
||||
result.setSuppressed(baseDomainFactory.convertToCompetitorDTO(suppressedCompetitor), true);
|
||||
}
|
||||
for (RaceColumn raceColumn : this.getRaceColumns()) {
|
||||
RaceColumnDTO raceColumnDTO = result.createEmptyRaceColumn(raceColumn.getName(), raceColumn.isMedalRace(),
|
||||
this.getScoringScheme().isValidInTotalScore(this, raceColumn, timePoint));
|
||||
for (Fleet fleet : raceColumn.getFleets()) {
|
||||
TimePoint latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive = null;
|
||||
RegattaAndRaceIdentifier raceIdentifier = null;
|
||||
RaceDTO race = null;
|
||||
TrackedRace trackedRace = raceColumn.getTrackedRace(fleet);
|
||||
|
||||
final FleetDTO fleetDTO = baseDomainFactory.convertToFleetDTO(raceColumn, fleet);
|
||||
if (trackedRace != null) {
|
||||
raceIdentifier = new RegattaNameAndRaceName(trackedRace.getTrackedRegatta().getRegatta()
|
||||
.getName(), trackedRace.getRace().getName());
|
||||
race = baseDomainFactory.createRaceDTO(trackedRegattaRegistry, false, raceIdentifier, trackedRace);
|
||||
if (trackedRace.hasStarted(timePoint) && trackedRace.hasGPSData() && trackedRace.hasWindData()) {
|
||||
TimePoint liveTimePointForTrackedRace = timePoint;
|
||||
final TimePoint endOfRace = trackedRace.getEndOfRace();
|
||||
if (endOfRace != null) {
|
||||
liveTimePointForTrackedRace = endOfRace;
|
||||
}
|
||||
latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive = liveTimePointForTrackedRace;
|
||||
}
|
||||
}
|
||||
result = new LeaderboardDTO(this.getScoreCorrection().getTimePointOfLastCorrectionsValidity() == null ? null
|
||||
: this.getScoreCorrection().getTimePointOfLastCorrectionsValidity().asDate(),
|
||||
this.getScoreCorrection() == null ? null : this.getScoreCorrection().getComment(), this
|
||||
.getScoringScheme().isHigherBetter(), new UUIDGenerator());
|
||||
result.competitors = new ArrayList<CompetitorDTO>();
|
||||
result.name = this.getName();
|
||||
result.competitorDisplayNames = new HashMap<CompetitorDTO, String>();
|
||||
for (Competitor suppressedCompetitor : this.getSuppressedCompetitors()) {
|
||||
result.setSuppressed(baseDomainFactory.convertToCompetitorDTO(suppressedCompetitor), true);
|
||||
}
|
||||
for (RaceColumn raceColumn : this.getRaceColumns()) {
|
||||
RaceColumnDTO raceColumnDTO = result.createEmptyRaceColumn(raceColumn.getName(), raceColumn.isMedalRace(),
|
||||
this.getScoringScheme().isValidInTotalScore(this, raceColumn, timePoint));
|
||||
for (Fleet fleet : raceColumn.getFleets()) {
|
||||
TimePoint latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive = null;
|
||||
RegattaAndRaceIdentifier raceIdentifier = null;
|
||||
RaceDTO race = null;
|
||||
TrackedRace trackedRace = raceColumn.getTrackedRace(fleet);
|
||||
|
||||
// Note: the RaceColumnDTO won't be created by the following addRace call because it has been created
|
||||
// above by the result.createEmptyRaceColumn call
|
||||
result.addRace(raceColumn.getName(), raceColumn.getExplicitFactor(), raceColumn.getFactor(),
|
||||
fleetDTO, raceColumn.isMedalRace(), raceIdentifier, race);
|
||||
if (latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive != null) {
|
||||
raceColumnDTO.setWhenLastTrackedRaceWasLive(fleetDTO, latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive.asDate());
|
||||
final FleetDTO fleetDTO = baseDomainFactory.convertToFleetDTO(fleet);
|
||||
if (trackedRace != null) {
|
||||
raceIdentifier = new RegattaNameAndRaceName(trackedRace.getTrackedRegatta().getRegatta().getName(),
|
||||
trackedRace.getRace().getName());
|
||||
race = baseDomainFactory.createRaceDTO(trackedRegattaRegistry, /* withGeoLocationData */ false, raceIdentifier, trackedRace);
|
||||
if (trackedRace.hasStarted(timePoint) && trackedRace.hasGPSData() && trackedRace.hasWindData()) {
|
||||
TimePoint liveTimePointForTrackedRace = timePoint;
|
||||
final TimePoint endOfRace = trackedRace.getEndOfRace();
|
||||
if (endOfRace != null) {
|
||||
liveTimePointForTrackedRace = endOfRace;
|
||||
}
|
||||
latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive = liveTimePointForTrackedRace;
|
||||
}
|
||||
}
|
||||
result.setCompetitorsFromBestToWorst(raceColumnDTO, baseDomainFactory.getCompetitorDTOList(this.getCompetitorsFromBestToWorst(raceColumn, timePoint)));
|
||||
|
||||
// Note: the RaceColumnDTO won't be created by the following addRace call because it has been created
|
||||
// above by the result.createEmptyRaceColumn call
|
||||
result.addRace(raceColumn.getName(), raceColumn.getExplicitFactor(), raceColumn.getFactor(), fleetDTO,
|
||||
raceColumn.isMedalRace(), raceIdentifier, race);
|
||||
if (latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive != null) {
|
||||
raceColumnDTO.setWhenLastTrackedRaceWasLive(fleetDTO,
|
||||
latestTimePointAfterQueryTimePointWhenATrackedRaceWasLive.asDate());
|
||||
}
|
||||
}
|
||||
result.setDelayToLiveInMillisForLatestRace(this.getDelayToLiveInMillis());
|
||||
result.rows = new HashMap<CompetitorDTO, LeaderboardRowDTO>();
|
||||
result.hasCarriedPoints = this.hasCarriedPoints();
|
||||
result.setCompetitorsFromBestToWorst(raceColumnDTO,
|
||||
baseDomainFactory.getCompetitorDTOList(this.getCompetitorsFromBestToWorst(raceColumn, timePoint)));
|
||||
}
|
||||
result.setDelayToLiveInMillisForLatestRace(this.getDelayToLiveInMillis());
|
||||
result.rows = new HashMap<CompetitorDTO, LeaderboardRowDTO>();
|
||||
result.hasCarriedPoints = this.hasCarriedPoints();
|
||||
if (this.getResultDiscardingRule() instanceof ThresholdBasedResultDiscardingRule) {
|
||||
result.discardThresholds = ((ThresholdBasedResultDiscardingRule) this.getResultDiscardingRule()).getDiscardIndexResultsStartingWithHowManyRaces();
|
||||
} else {
|
||||
result.discardThresholds = null;
|
||||
}
|
||||
// Computing the competitor leg ranks is expensive, especially in live mode, in case new events keep invalidating
|
||||
// the ranks cache in TrackedLegImpl. Then problem then is that the sorting based on wind data is repeated for each
|
||||
// competitor, leading to square effort. We therefore need to compute the leg ranks for those race where leg details
|
||||
// are requested only once and pass them into getLeaderboardEntryDTO
|
||||
final Map<Leg, LinkedHashMap<Competitor, Integer>> legRanksCache = new HashMap<Leg, LinkedHashMap<Competitor,Integer>>();
|
||||
// competitor, leading to square effort. We therefore need to compute the leg ranks for those race where leg
|
||||
// details
|
||||
// are requested only once and pass them into getLeaderboardEntryDTO
|
||||
final Map<Leg, LinkedHashMap<Competitor, Integer>> legRanksCache = new HashMap<Leg, LinkedHashMap<Competitor, Integer>>();
|
||||
for (final RaceColumn raceColumn : this.getRaceColumns()) {
|
||||
// if details for the column are requested, cache the leg's ranks
|
||||
if (namesOfRaceColumnsForWhichToLoadLegDetails != null
|
||||
&& namesOfRaceColumnsForWhichToLoadLegDetails.contains(raceColumn.getName())) {
|
||||
for (Fleet fleet : raceColumn.getFleets()) {
|
||||
TrackedRace trackedRace = raceColumn.getTrackedRace(fleet);
|
||||
if (trackedRace != null) {
|
||||
trackedRace.getRace().getCourse().lockForRead();
|
||||
try {
|
||||
for (TrackedLeg trackedLeg : trackedRace.getTrackedLegs()) {
|
||||
legRanksCache.put(trackedLeg.getLeg(), trackedLeg.getRanks(timePoint));
|
||||
}
|
||||
} finally {
|
||||
trackedRace.getRace().getCourse().unlockAfterRead();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (final Competitor competitor : this.getCompetitorsFromBestToWorst(timePoint)) {
|
||||
CompetitorDTO competitorDTO = baseDomainFactory.convertToCompetitorDTO(competitor);
|
||||
LeaderboardRowDTO row = new LeaderboardRowDTO();
|
||||
row.competitor = competitorDTO;
|
||||
row.fieldsByRaceColumnName = new HashMap<String, LeaderboardEntryDTO>();
|
||||
row.carriedPoints = this.hasCarriedPoints(competitor) ? this.getCarriedPoints(competitor) : null;
|
||||
row.totalPoints = this.getTotalPoints(competitor, timePoint);
|
||||
addOverallDetailsToRow(timePoint, competitor, row);
|
||||
result.competitors.add(competitorDTO);
|
||||
Map<String, Future<LeaderboardEntryDTO>> futuresForColumnName = new HashMap<String, Future<LeaderboardEntryDTO>>();
|
||||
for (final RaceColumn raceColumn : this.getRaceColumns()) {
|
||||
// if details for the column are requested, cache the leg's ranks
|
||||
if (namesOfRaceColumnsForWhichToLoadLegDetails != null
|
||||
&& namesOfRaceColumnsForWhichToLoadLegDetails.contains(raceColumn.getName())) {
|
||||
for (Fleet fleet : raceColumn.getFleets()) {
|
||||
TrackedRace trackedRace = raceColumn.getTrackedRace(fleet);
|
||||
if (trackedRace != null) {
|
||||
trackedRace.getRace().getCourse().lockForRead();
|
||||
try {
|
||||
for (TrackedLeg trackedLeg : trackedRace.getTrackedLegs()) {
|
||||
legRanksCache.put(trackedLeg.getLeg(), trackedLeg.getRanks(timePoint));
|
||||
RunnableFuture<LeaderboardEntryDTO> future = new FutureTask<LeaderboardEntryDTO>(
|
||||
new Callable<LeaderboardEntryDTO>() {
|
||||
@Override
|
||||
public LeaderboardEntryDTO call() {
|
||||
try {
|
||||
Entry entry = AbstractSimpleLeaderboardImpl.this.getEntry(competitor, raceColumn,
|
||||
timePoint);
|
||||
return getLeaderboardEntryDTO(
|
||||
entry,
|
||||
raceColumn,
|
||||
competitor,
|
||||
timePoint,
|
||||
namesOfRaceColumnsForWhichToLoadLegDetails != null
|
||||
&& namesOfRaceColumnsForWhichToLoadLegDetails.contains(raceColumn
|
||||
.getName()), waitForLatestAnalyses, legRanksCache,
|
||||
baseDomainFactory);
|
||||
} catch (NoWindException e) {
|
||||
logger.info("Exception trying to compute leaderboard entry for competitor "
|
||||
+ competitor.getName() + " in race column " + raceColumn.getName() + ": "
|
||||
+ e.getMessage());
|
||||
logger.throwing(AbstractSimpleLeaderboardImpl.class.getName(),
|
||||
"computeLeaderboardByName.future.call()", e);
|
||||
throw new NoWindError(e);
|
||||
}
|
||||
} finally {
|
||||
trackedRace.getRace().getCourse().unlockAfterRead();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
executor.execute(future);
|
||||
futuresForColumnName.put(raceColumn.getName(), future);
|
||||
}
|
||||
for (Map.Entry<String, Future<LeaderboardEntryDTO>> raceColumnNameAndFuture : futuresForColumnName
|
||||
.entrySet()) {
|
||||
try {
|
||||
row.fieldsByRaceColumnName.put(raceColumnNameAndFuture.getKey(), raceColumnNameAndFuture.getValue()
|
||||
.get());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
// See also bug 1371: for stability reasons, don't let the exception percolate but rather accept
|
||||
// null values.
|
||||
// If new evidence is provided, a re-calculation of the leaderboard will be triggered anyway. So
|
||||
// this helps
|
||||
// robustness from a user's perspective.
|
||||
logger.log(
|
||||
Level.SEVERE,
|
||||
AbstractSimpleLeaderboardImpl.class.getName() + ".computeDTO(" + this.getName() + ", "
|
||||
+ timePoint + ", " + namesOfRaceColumnsForWhichToLoadLegDetails
|
||||
+ "): exception during computing leaderboard entry for competitor "
|
||||
+ competitor.getName() + " in race column " + raceColumnNameAndFuture.getKey()
|
||||
+ ". Leaving empty.", e);
|
||||
}
|
||||
}
|
||||
for (final Competitor competitor : this.getCompetitorsFromBestToWorst(timePoint)) {
|
||||
CompetitorDTO competitorDTO = baseDomainFactory.convertToCompetitorDTO(competitor);
|
||||
LeaderboardRowDTO row = new LeaderboardRowDTO();
|
||||
row.competitor = competitorDTO;
|
||||
row.fieldsByRaceColumnName = new HashMap<String, LeaderboardEntryDTO>();
|
||||
row.carriedPoints = this.hasCarriedPoints(competitor) ? this.getCarriedPoints(competitor) : null;
|
||||
row.totalPoints = this.getTotalPoints(competitor, timePoint);
|
||||
addOverallDetailsToRow(timePoint, competitor, row);
|
||||
result.competitors.add(competitorDTO);
|
||||
Map<String, Future<LeaderboardEntryDTO>> futuresForColumnName = new HashMap<String, Future<LeaderboardEntryDTO>>();
|
||||
for (final RaceColumn raceColumn : this.getRaceColumns()) {
|
||||
RunnableFuture<LeaderboardEntryDTO> future = new FutureTask<LeaderboardEntryDTO>(new Callable<LeaderboardEntryDTO>() {
|
||||
@Override
|
||||
public LeaderboardEntryDTO call() {
|
||||
try {
|
||||
Entry entry = AbstractSimpleLeaderboardImpl.this.getEntry(competitor, raceColumn, timePoint);
|
||||
return getLeaderboardEntryDTO(entry, raceColumn, competitor, timePoint,
|
||||
namesOfRaceColumnsForWhichToLoadLegDetails != null
|
||||
&& namesOfRaceColumnsForWhichToLoadLegDetails.contains(raceColumn.getName()),
|
||||
waitForLatestAnalyses, legRanksCache, baseDomainFactory);
|
||||
} catch (NoWindException e) {
|
||||
logger.info("Exception trying to compute leaderboard entry for competitor "+competitor.getName()+
|
||||
" in race column "+raceColumn.getName()+": "+e.getMessage());
|
||||
logger.throwing(AbstractSimpleLeaderboardImpl.class.getName(), "computeLeaderboardByName.future.call()", e);
|
||||
throw new NoWindError(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
executor.execute(future);
|
||||
futuresForColumnName.put(raceColumn.getName(), future);
|
||||
}
|
||||
for (Map.Entry<String, Future<LeaderboardEntryDTO>> raceColumnNameAndFuture : futuresForColumnName.entrySet()) {
|
||||
try {
|
||||
row.fieldsByRaceColumnName.put(raceColumnNameAndFuture.getKey(), raceColumnNameAndFuture.getValue().get());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
// See also bug 1371: for stability reasons, don't let the exception percolate but rather accept null values.
|
||||
// If new evidence is provided, a re-calculation of the leaderboard will be triggered anyway. So this helps
|
||||
// robustness from a user's perspective.
|
||||
logger.log(Level.SEVERE, AbstractSimpleLeaderboardImpl.class.getName()+".computeDTO("
|
||||
+this.getName()+", "+timePoint+", "+namesOfRaceColumnsForWhichToLoadLegDetails+
|
||||
"): exception during computing leaderboard entry for competitor "+competitor.getName()+
|
||||
" in race column "+raceColumnNameAndFuture.getKey()+". Leaving empty.", e);
|
||||
}
|
||||
}
|
||||
result.rows.put(competitorDTO, row);
|
||||
String displayName = this.getDisplayName(competitor);
|
||||
if (displayName != null) {
|
||||
result.competitorDisplayNames.put(competitorDTO, displayName);
|
||||
}
|
||||
}
|
||||
// set race ranks for all LeaderboardEntryDTO's
|
||||
for(RaceColumnDTO raceColumnDTO: result.getRaceList()) {
|
||||
int raceRank = 1;
|
||||
for(CompetitorDTO competitorDTO: result.getCompetitorsFromBestToWorst(raceColumnDTO)) {
|
||||
LeaderboardRowDTO leaderboardRowDTO = result.rows.get(competitorDTO);
|
||||
LeaderboardEntryDTO leaderboardEntryDTO = leaderboardRowDTO.fieldsByRaceColumnName.get(raceColumnDTO.name);
|
||||
leaderboardEntryDTO.rank = raceRank++;
|
||||
}
|
||||
result.rows.put(competitorDTO, row);
|
||||
String displayName = this.getDisplayName(competitor);
|
||||
if (displayName != null) {
|
||||
result.competitorDisplayNames.put(competitorDTO, displayName);
|
||||
}
|
||||
}
|
||||
logger.info("computeLeaderboardByName("+this.getName()+", "+timePoint+", "+namesOfRaceColumnsForWhichToLoadLegDetails+") took "+
|
||||
(System.currentTimeMillis()-startOfRequestHandling)+"ms");
|
||||
return result;
|
||||
@@ -1208,7 +1224,7 @@ public abstract class AbstractSimpleLeaderboardImpl implements Leaderboard, Race
|
||||
}
|
||||
}
|
||||
final Fleet fleet = entry.getFleet();
|
||||
entryDTO.fleet = fleet == null ? null : baseDomainFactory.convertToFleetDTO(raceColumn, fleet);
|
||||
entryDTO.fleet = fleet == null ? null : baseDomainFactory.convertToFleetDTO(fleet);
|
||||
return entryDTO;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.sap.sailing.util;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
import com.sap.sailing.domain.common.Cloner;
|
||||
|
||||
public class ClonerImpl implements Cloner {
|
||||
public void clone(Object from, Object to) {
|
||||
try {
|
||||
Class<?> c = from.getClass();
|
||||
while (c != null) {
|
||||
for (Field field : c.getDeclaredFields()) {
|
||||
if ((field.getModifiers() & Modifier.FINAL) == 0) {
|
||||
field.setAccessible(true);
|
||||
Object value;
|
||||
value = field.get(from);
|
||||
field.set(to, value);
|
||||
}
|
||||
}
|
||||
c = c.getSuperclass();
|
||||
}
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-4
@@ -11,6 +11,7 @@ import com.google.gwt.user.cellview.client.Column;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.RegattaNameAndRaceName;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
import com.sap.sailing.domain.common.dto.IncrementalOrFullLeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardRowDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnDTO;
|
||||
@@ -137,7 +138,7 @@ public class GwtTestCaseColumnToggling extends GWTTestCase {
|
||||
public void onSuccess(Void result) {
|
||||
System.out.println("Added column to leaderboard.");
|
||||
RaceColumnDTO race = new RaceColumnDTO(/* isValidInTotalScore */ null);
|
||||
race.name = COLUMN1_NAME;
|
||||
race.setName(COLUMN1_NAME);
|
||||
race.setMedalRace(false);
|
||||
leaderboardPanel.addColumn(leaderboardPanel.createRaceColumn(race));
|
||||
linkTrackedRace();
|
||||
@@ -165,7 +166,7 @@ public class GwtTestCaseColumnToggling extends GWTTestCase {
|
||||
private void getLeaderboard(){
|
||||
ArrayList<String> al = new ArrayList<String>();
|
||||
al.add(COLUMN1_NAME);
|
||||
service.getLeaderboardByName(LEADERBOARD_NAME, new Date(), al, new AsyncCallback<LeaderboardDTO>() {
|
||||
service.getLeaderboardByName(LEADERBOARD_NAME, new Date(), al, /* previousLeaderboardId */ null, new AsyncCallback<IncrementalOrFullLeaderboardDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
fail("Failed to get leaderboard.");
|
||||
@@ -173,10 +174,10 @@ public class GwtTestCaseColumnToggling extends GWTTestCase {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(LeaderboardDTO result) {
|
||||
public void onSuccess(IncrementalOrFullLeaderboardDTO result) {
|
||||
System.out.println("Got leaderboard.");
|
||||
|
||||
leaderboard = result;
|
||||
leaderboard = result.getLeaderboardDTO(/* previousVersion */ null);
|
||||
leaderboardPanel.updateLeaderboard(leaderboard);
|
||||
for (int i = 0; i < leaderboardPanel.getLeaderboardTable()
|
||||
.getColumnCount(); i++) {
|
||||
|
||||
+16
-6
@@ -9,6 +9,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -24,8 +25,7 @@ public class TestColumnSwapping {
|
||||
private LeaderboardDTO lb = null;
|
||||
private static final String LEADERBOARDNAME = "test";
|
||||
private static final String DEFAULT_FLEET_NAME = "Default";
|
||||
private static final String DEFAULT_SERIES_NAME = "Default";
|
||||
private static final FleetDTO DEFAULT_FLEET = new FleetDTO(DEFAULT_FLEET_NAME, DEFAULT_SERIES_NAME, /* ordering */ 0, /* color */ null);
|
||||
private static final FleetDTO DEFAULT_FLEET = new FleetDTO(DEFAULT_FLEET_NAME, /* ordering */ 0, /* color */ null);
|
||||
private SailingServiceImpl service;
|
||||
private LeaderboardDTO leaderboardOriginalDTO;
|
||||
private LeaderboardDTO leaderboardDTO;
|
||||
@@ -53,7 +53,12 @@ public class TestColumnSwapping {
|
||||
leaderboardCreationDate = new Date();
|
||||
try {
|
||||
// get Leaderboard with name and current date
|
||||
leaderboardOriginalDTO = new LeaderboardDTO(null, null, /* higherScoreIsBetter */ false);
|
||||
leaderboardOriginalDTO = new LeaderboardDTO(null, null, /* higherScoreIsBetter */ false, new LeaderboardDTO.UUIDGenerator() {
|
||||
@Override
|
||||
public String generateRandomUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
});
|
||||
leaderboardOriginalDTO.addRace("Race1", /* explicitFactor */ null, 1., DEFAULT_FLEET, true, null, null);
|
||||
leaderboardOriginalDTO.addRace("Race3", /* explicitFactor */ null, 1., DEFAULT_FLEET, true, null, null);
|
||||
leaderboardOriginalDTO.addRace("Race2", /* explicitFactor */ null, 1., DEFAULT_FLEET, true, null, null);
|
||||
@@ -90,7 +95,7 @@ public class TestColumnSwapping {
|
||||
sailingService.moveLeaderboardColumnUp(TEST_LEADERBOARD_NAME, races[2]);
|
||||
sailingService.updateIsMedalRace(TEST_LEADERBOARD_NAME, races[0], true);
|
||||
sailingService.updateIsMedalRace(TEST_LEADERBOARD_NAME, races[2], false);
|
||||
lb = sailingService.getLeaderboardByName(TEST_LEADERBOARD_NAME, new Date(), /* races to load */ null);
|
||||
lb = sailingService.getLeaderboardByName(TEST_LEADERBOARD_NAME, new Date(), /* races to load */ null, /* previous leaderboard ID */ null).getLeaderboardDTO(/* previousVersion */ null);
|
||||
} catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
fail(e.getLocalizedMessage());
|
||||
@@ -110,7 +115,12 @@ public class TestColumnSwapping {
|
||||
|
||||
@Test
|
||||
public void testLeaderBoardDTOMethods() {
|
||||
lb = new LeaderboardDTO(null, null, /* higherScoreIsBetter */ false);
|
||||
lb = new LeaderboardDTO(null, null, /* higherScoreIsBetter */ false, new LeaderboardDTO.UUIDGenerator() {
|
||||
@Override
|
||||
public String generateRandomUUID() {
|
||||
return UUID.randomUUID().toString();
|
||||
}
|
||||
});
|
||||
assertNotNull("Leaderboard != NULL", lb);
|
||||
lb.addRace("1", /* explicitFactor */ null, 1., DEFAULT_FLEET, false, null, null);
|
||||
lb.addRace("2", /* explicitFactor */ null, 1., DEFAULT_FLEET, false, null, null);
|
||||
@@ -125,7 +135,7 @@ public class TestColumnSwapping {
|
||||
public void testColumnSwappingFabian() {
|
||||
service.moveLeaderboardColumnUp(LEADERBOARDNAME, "Race3");
|
||||
try {
|
||||
leaderboardDTO = service.getLeaderboardByName(LEADERBOARDNAME, leaderboardCreationDate, leglist);
|
||||
leaderboardDTO = service.getLeaderboardByName(LEADERBOARDNAME, leaderboardCreationDate, leglist, /* previous leaderboard ID */ null).getLeaderboardDTO(/* previousVersion */ null);
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
eclipse.preferences.version=1
|
||||
entryPointModules=
|
||||
filesCopiedToWebInfLib=gwt-servlet.jar
|
||||
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgLiAtbG9jYWxXb3JrZXJzIDMgLXN0cmljdCAtbG9nTGV2ZWwgVFJBQ0VdXT48L2V4dHJhLWFyZ3M+PHZtLWFyZ3M+PCFbQ0RBVEFbLVhteDIwMjRtIC1EZ3d0LnVzZWFyY2hpdmVzPWZhbHNlXV0+PC92bS1hcmdzPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5BZG1pbkNvbnNvbGU8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuTGVhZGVyYm9hcmQ8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuTGVhZGVyYm9hcmRFZGl0aW5nPC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlJhY2VCb2FyZDwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5TcGVjdGF0b3I8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuVXNlck1hbmFnZW1lbnQ8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuVHZWaWV3PC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlZpZGVvUG9wdXA8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuWW91dHViZVBvcHVwPC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlBvbGFyU2hlZXRzPC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlJlZ2F0dGFPdmVydmlldzwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5TaW11bGF0b3I8L2VudHJ5LXBvaW50LW1vZHVsZT48L2d3dC1jb21waWxlLXNldHRpbmdzPg\=\=
|
||||
eclipse.preferences.version=1
|
||||
entryPointModules=
|
||||
filesCopiedToWebInfLib=gwt-servlet.jar
|
||||
gwtCompileSettings=PGd3dC1jb21waWxlLXNldHRpbmdzPjxsb2ctbGV2ZWw+SU5GTzwvbG9nLWxldmVsPjxvdXRwdXQtc3R5bGU+T0JGVVNDQVRFRDwvb3V0cHV0LXN0eWxlPjxleHRyYS1hcmdzPjwhW0NEQVRBWy13YXIgLiAtbG9jYWxXb3JrZXJzIDMgLXN0cmljdCAtbG9nTGV2ZWwgVFJBQ0VdXT48L2V4dHJhLWFyZ3M+PHZtLWFyZ3M+PCFbQ0RBVEFbLVhteDIwMjRtIC1EZ3d0LnVzZWFyY2hpdmVzPWZhbHNlXV0+PC92bS1hcmdzPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5BZG1pbkNvbnNvbGU8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuTGVhZGVyYm9hcmQ8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuTGVhZGVyYm9hcmRFZGl0aW5nPC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlJhY2VCb2FyZDwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5TcGVjdGF0b3I8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuVXNlck1hbmFnZW1lbnQ8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuVHZWaWV3PC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlZpZGVvUG9wdXA8L2VudHJ5LXBvaW50LW1vZHVsZT48ZW50cnktcG9pbnQtbW9kdWxlPmNvbS5zYXAuc2FpbGluZy5nd3QudWkuWW91dHViZVBvcHVwPC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlBvbGFyU2hlZXRzPC9lbnRyeS1wb2ludC1tb2R1bGU+PGVudHJ5LXBvaW50LW1vZHVsZT5jb20uc2FwLnNhaWxpbmcuZ3d0LnVpLlJlZ2F0dGFPdmVydmlldzwvZW50cnktcG9pbnQtbW9kdWxlPjxlbnRyeS1wb2ludC1tb2R1bGU+Y29tLnNhcC5zYWlsaW5nLmd3dC51aS5TaW11bGF0b3I8L2VudHJ5LXBvaW50LW1vZHVsZT48L2d3dC1jb21waWxlLXNldHRpbmdzPg\=\=
|
||||
@@ -1,43 +1,42 @@
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Sailing App GWT UI
|
||||
Bundle-SymbolicName: com.sap.sailing.gwt.ui
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: com.sap.sailing.domain,
|
||||
com.sap.sailing.domain.shared.android;bundle-version="1.0.0",
|
||||
com.sap.sailing.server.gateway,
|
||||
com.sap.sailing.server,
|
||||
com.sap.sailing.domain.tractracadapter,
|
||||
com.sap.sailing.mongodb,
|
||||
com.mongodb.driver;bundle-version="2.6.2",
|
||||
com.sap.sailing.domain.swisstimingadapter,
|
||||
com.sap.sailing.domain.persistence,
|
||||
com.sap.sailing.domain.swisstimingadapter.persistence,
|
||||
com.sap.sailing.domain.tractracadapter.persistence,
|
||||
com.google.gwt.osgi;bundle-version="2.4.0",
|
||||
com.sap.sailing.domain.common,
|
||||
com.sap.sailing.resultimport,
|
||||
org.moxieapps.gwt.highcharts;bundle-version="1.5.0",
|
||||
com.sap.sailing.geocoding,
|
||||
com.sap.sailing.server.replication,
|
||||
com.googlecode.java-diff-utils;bundle-version="1.3.0",
|
||||
com.sap.sailing.freg.resultimport,
|
||||
com.sap.sailing.domain.swisstimingreplayadapter,
|
||||
com.sap.sailing.simulator;bundle-version="1.0.0"
|
||||
Bundle-Activator: com.sap.sailing.gwt.ui.server.Activator
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Export-Package: com.sap.sailing.gwt.ui.client.shared.media
|
||||
Import-Package: javax.jms;version="1.1.0",
|
||||
javax.servlet;version="2.5.0",
|
||||
javax.servlet.http;version="2.5.0",
|
||||
org.json.simple,
|
||||
org.json.simple.parser,
|
||||
org.osgi.framework,
|
||||
org.osgi.util.tracker
|
||||
Web-ContextPath: /gwt
|
||||
Bundle-ClassPath: WEB-INF/classes/,
|
||||
WEB-INF/lib/gwt-maps.jar,
|
||||
WEB-INF/lib/gwt-servlet.jar
|
||||
TrackLifecycle: true
|
||||
Manifest-Version: 1.0
|
||||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: Sailing App GWT UI
|
||||
Bundle-SymbolicName: com.sap.sailing.gwt.ui
|
||||
Bundle-Version: 1.0.0.qualifier
|
||||
Bundle-Vendor: SAP
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
|
||||
Require-Bundle: com.sap.sailing.domain,
|
||||
com.sap.sailing.domain.shared.android;bundle-version="1.0.0",
|
||||
com.sap.sailing.server.gateway,
|
||||
com.sap.sailing.server,
|
||||
com.sap.sailing.domain.tractracadapter,
|
||||
com.sap.sailing.mongodb,
|
||||
com.mongodb.driver;bundle-version="2.6.2",
|
||||
com.sap.sailing.domain.swisstimingadapter,
|
||||
com.sap.sailing.domain.persistence,
|
||||
com.sap.sailing.domain.swisstimingadapter.persistence,
|
||||
com.sap.sailing.domain.tractracadapter.persistence,
|
||||
com.google.gwt.osgi;bundle-version="2.4.0",
|
||||
com.sap.sailing.domain.common,
|
||||
com.sap.sailing.resultimport,
|
||||
org.moxieapps.gwt.highcharts;bundle-version="1.5.0",
|
||||
com.sap.sailing.geocoding,
|
||||
com.sap.sailing.server.replication,
|
||||
com.googlecode.java-diff-utils;bundle-version="1.3.0",
|
||||
com.sap.sailing.freg.resultimport,
|
||||
com.sap.sailing.domain.swisstimingreplayadapter,
|
||||
com.sap.sailing.simulator;bundle-version="1.0.0"
|
||||
Bundle-Activator: com.sap.sailing.gwt.ui.server.Activator
|
||||
Bundle-ActivationPolicy: lazy
|
||||
Import-Package: javax.jms;version="1.1.0",
|
||||
javax.servlet;version="2.5.0",
|
||||
javax.servlet.http;version="2.5.0",
|
||||
org.json.simple,
|
||||
org.json.simple.parser,
|
||||
org.osgi.framework,
|
||||
org.osgi.util.tracker
|
||||
Web-ContextPath: /gwt
|
||||
Bundle-ClassPath: WEB-INF/classes/,
|
||||
WEB-INF/lib/gwt-maps.jar,
|
||||
WEB-INF/lib/gwt-servlet.jar
|
||||
TrackLifecycle: true
|
||||
@@ -4,6 +4,16 @@
|
||||
<stringAttribute key="com.google.gdt.eclipse.suiteMainTypeProcessor.PREVIOUSLY_SET_MAIN_TYPE_NAME" value="com.google.gwt.dev.GWTShell"/>
|
||||
<booleanAttribute key="com.google.gdt.eclipse.suiteWarArgumentProcessor.IS_WAR_FROM_PROJECT_PROPERTIES" value="true"/>
|
||||
<listAttribute key="com.google.gwt.eclipse.core.ENTRY_POINT_MODULES">
|
||||
<listEntry value="com.sap.sailing.gwt.ui.YoutubePopup"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.VideoPopup"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.UserManagement"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.TvView"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.Spectator"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.RaceBoard"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.PolarSheets"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.LeaderboardEditing"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.Leaderboard"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.AdminConsole"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.RegattaOverview"/>
|
||||
<listEntry value="com.sap.sailing.gwt.ui.Simulator"/>
|
||||
</listAttribute>
|
||||
@@ -22,6 +32,7 @@
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry containerPath="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6" javaProject="com.sap.sailing.gwt.ui" path="1" type="4"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.sap.sailing.gwt.ui/src/main/resources" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.sap.sailing.gwt.ui/src/main/java" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.sap.sailing.simulator/src" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.sap.sailing.domain/src" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.googlecode.java-diff-utils/src" path="3" type="2"/> "/>
|
||||
<listEntry value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <runtimeClasspathEntry internalArchive="/com.sap.sailing.domain.common/src" path="3" type="2"/> "/>
|
||||
@@ -48,7 +59,7 @@
|
||||
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="com.google.gwt.eclipse.core.moduleClasspathProvider"/>
|
||||
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war "${project_loc:com.sap.sailing.gwt.ui}" -noserver -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -codeServerPort 9997 -startupUrl /gwt/AdminConsole.html com.sap.sailing.gwt.ui.AdminConsole -startupUrl /gwt/LeaderboardEditing.html com.sap.sailing.gwt.ui.LeaderboardEditing -startupUrl /gwt/UserManagement.html com.sap.sailing.gwt.ui.UserManagement -startupUrl /gwt/Leaderboard.html com.sap.sailing.gwt.ui.Leaderboard -startupUrl /gwt/Spectator.html com.sap.sailing.gwt.ui.Spectator -startupUrl /gwt/RaceBoard.html com.sap.sailing.gwt.ui.RaceBoard -startupUrl /gwt/TvView.html com.sap.sailing.gwt.ui.TvView -startupUrl /gwt/PolarSheets.html com.sap.sailing.gwt.ui.PolarSheets -startupUrl /gwt/RegattaOverview.html com.sap.sailing.gwt.ui.RegattaOverview -startupUrl /gwt/Simulator.html com.sap.sailing.gwt.ui.Simulator com.sap.sailing.gwt.ui.RegattaOverview"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-war "${project_loc:com.sap.sailing.gwt.ui}" -noserver -remoteUI "${gwt_remote_ui_server_port}:${unique_id}" -logLevel INFO -codeServerPort 9997 -startupUrl /gwt/AdminConsole.html com.sap.sailing.gwt.ui.AdminConsole -startupUrl /gwt/LeaderboardEditing.html com.sap.sailing.gwt.ui.LeaderboardEditing -startupUrl /gwt/UserManagement.html com.sap.sailing.gwt.ui.UserManagement -startupUrl /gwt/Leaderboard.html com.sap.sailing.gwt.ui.Leaderboard -startupUrl /gwt/Spectator.html com.sap.sailing.gwt.ui.Spectator -startupUrl /gwt/RaceBoard.html com.sap.sailing.gwt.ui.RaceBoard -startupUrl /gwt/TvView.html com.sap.sailing.gwt.ui.TvView -startupUrl /gwt/PolarSheets.html com.sap.sailing.gwt.ui.PolarSheets -startupUrl /gwt/RegattaOverview.html com.sap.sailing.gwt.ui.RegattaOverview -startupUrl /gwt/Simulator.html com.sap.sailing.gwt.ui.RegattaOverview com.sap.sailing.gwt.ui.AdminConsole com.sap.sailing.gwt.ui.Leaderboard com.sap.sailing.gwt.ui.LeaderboardEditing com.sap.sailing.gwt.ui.PolarSheets com.sap.sailing.gwt.ui.RaceBoard com.sap.sailing.gwt.ui.Spectator com.sap.sailing.gwt.ui.TvView com.sap.sailing.gwt.ui.UserManagement com.sap.sailing.gwt.ui.VideoPopup com.sap.sailing.gwt.ui.YoutubePopup com.sap.sailing.gwt.ui.Simulator"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="com.sap.sailing.gwt.ui"/>
|
||||
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx2048m -XX:MaxPermSize=512m"/>
|
||||
</launchConfiguration>
|
||||
+28
-2
@@ -4,29 +4,55 @@ import java.util.Collection;
|
||||
import java.util.Date;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.dto.IncrementalOrFullLeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
import com.sap.sailing.gwt.ui.client.SailingServiceAsync;
|
||||
|
||||
/**
|
||||
* Performs a result adaptation from {@link IncrementalOrFullLeaderboardDTO} and {@link LeaderboardDTO}, encapsulating
|
||||
* the logic how differential, incremental leaderboard fetching and transmission works. This helps guarantee the
|
||||
* requirement of {@link IncrementalOrFullLeaderboardDTO#getLeaderboardDTO(LeaderboardDTO)} (only pass <code>null</code>
|
||||
* as the previous leaderboard if <code>null</code> was passed as identifier of the previous leaderboard to
|
||||
* {@link SailingServiceAsync#getLeaderboardByName(String, Date, Collection, String, AsyncCallback)} too.
|
||||
*
|
||||
* @author Frank Mittag, Axel Uhl (d043530)
|
||||
*
|
||||
*/
|
||||
public class GetLeaderboardByNameAction extends DefaultAsyncAction<LeaderboardDTO> {
|
||||
private final SailingServiceAsync sailingService;
|
||||
private final String leaderboardName;
|
||||
private final Date date;
|
||||
private final Collection<String> namesOfRacesForWhichToLoadLegDetails;
|
||||
private final LeaderboardDTO previousLeaderboard;
|
||||
|
||||
public GetLeaderboardByNameAction(SailingServiceAsync sailingService, String leaderboardName, Date date,
|
||||
final Collection<String> namesOfRacesForWhichToLoadLegDetails, AsyncCallback<LeaderboardDTO> callback) {
|
||||
final Collection<String> namesOfRacesForWhichToLoadLegDetails, LeaderboardDTO previousLeaderboard, AsyncCallback<LeaderboardDTO> callback) {
|
||||
super(callback);
|
||||
this.sailingService = sailingService;
|
||||
this.leaderboardName = leaderboardName;
|
||||
this.date = date;
|
||||
this.namesOfRacesForWhichToLoadLegDetails = namesOfRacesForWhichToLoadLegDetails;
|
||||
this.previousLeaderboard = previousLeaderboard;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(AsyncActionsExecutor asyncActionsExecutor) {
|
||||
final AsyncCallback<LeaderboardDTO> wrapperCallback = getWrapperCallback(asyncActionsExecutor);
|
||||
sailingService
|
||||
.getLeaderboardByName(leaderboardName, date, namesOfRacesForWhichToLoadLegDetails,
|
||||
(AsyncCallback<LeaderboardDTO>) getWrapperCallback(asyncActionsExecutor));
|
||||
previousLeaderboard==null?null:previousLeaderboard.getId(),
|
||||
new AsyncCallback<IncrementalOrFullLeaderboardDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
wrapperCallback.onFailure(caught);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(IncrementalOrFullLeaderboardDTO result) {
|
||||
LeaderboardDTO leaderboardDTOResult = result.getLeaderboardDTO(previousLeaderboard);
|
||||
wrapperCallback.onSuccess(leaderboardDTOResult);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -49,11 +49,11 @@ public class GetRaceMapDataAction extends DefaultAsyncAction<RaceMapDataDTO> {
|
||||
};
|
||||
Map<String, Date> fromByCompetitorIdAsString = new HashMap<String, Date>();
|
||||
for (Map.Entry<CompetitorDTO, Date> fromEntry : from.entrySet()) {
|
||||
fromByCompetitorIdAsString.put(fromEntry.getKey().idAsString, fromEntry.getValue());
|
||||
fromByCompetitorIdAsString.put(fromEntry.getKey().getIdAsString(), fromEntry.getValue());
|
||||
}
|
||||
Map<String, Date> toByCompetitorIdAsString = new HashMap<String, Date>();
|
||||
for (Map.Entry<CompetitorDTO, Date> toEntry : to.entrySet()) {
|
||||
toByCompetitorIdAsString.put(toEntry.getKey().idAsString, toEntry.getValue());
|
||||
toByCompetitorIdAsString.put(toEntry.getKey().getIdAsString(), toEntry.getValue());
|
||||
}
|
||||
sailingService.getRaceMapData(raceIdentifier, date, fromByCompetitorIdAsString, toByCompetitorIdAsString,
|
||||
extrapolate, uncompactingCallback);
|
||||
|
||||
+4
-4
@@ -41,13 +41,13 @@ public abstract class AbstractEventManagementPanel extends AbstractRegattaPanel
|
||||
Collections.sort(regattasSortedByName, new Comparator<RegattaDTO>() {
|
||||
@Override
|
||||
public int compare(RegattaDTO o1, RegattaDTO o2) {
|
||||
return o1.name.compareTo(o2.name);
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
for (RegattaDTO regatta : regattasSortedByName) {
|
||||
this.availableRegattas.add(regatta);
|
||||
this.availableRegattasListBox.addItem(regatta.name);
|
||||
if(selectedRegatta != null && selectedRegatta.name.equals(regatta.name)) {
|
||||
this.availableRegattasListBox.addItem(regatta.getName());
|
||||
if(selectedRegatta != null && selectedRegatta.getName().equals(regatta.getName())) {
|
||||
this.availableRegattasListBox.setSelectedIndex(this.availableRegattasListBox.getItemCount() - 1);
|
||||
}
|
||||
}
|
||||
@@ -68,7 +68,7 @@ public abstract class AbstractEventManagementPanel extends AbstractRegattaPanel
|
||||
if (selIndex > 0) {
|
||||
String itemText = this.availableRegattasListBox.getItemText(selIndex);
|
||||
for (RegattaDTO regatta : this.availableRegattas) {
|
||||
if (regatta.name.equals(itemText)) {
|
||||
if (regatta.getName().equals(itemText)) {
|
||||
result = regatta;
|
||||
break;
|
||||
}
|
||||
|
||||
+4
-4
@@ -220,14 +220,14 @@ public abstract class AbstractTrackedRacesListComposite extends SimplePanel impl
|
||||
Column<RaceDTO, SafeHtml> raceNameColumn = new Column<RaceDTO, SafeHtml>(anchorCell) {
|
||||
@Override
|
||||
public SafeHtml getValue(RaceDTO raceDTO) {
|
||||
return SafeHtmlUtils.fromString(raceDTO.name);
|
||||
return SafeHtmlUtils.fromString(raceDTO.getName());
|
||||
}
|
||||
};
|
||||
raceNameColumn.setSortable(true);
|
||||
columnSortHandler.setComparator(raceNameColumn, new Comparator<RaceDTO>() {
|
||||
@Override
|
||||
public int compare(RaceDTO r1, RaceDTO r2) {
|
||||
return r1.name.compareTo(r2.name);
|
||||
return r1.getName().compareTo(r2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -371,7 +371,7 @@ public abstract class AbstractTrackedRacesListComposite extends SimplePanel impl
|
||||
String textAsUppercase = word.toUpperCase().trim();
|
||||
if (!raceDTO.getRegattaName().toUpperCase().contains(textAsUppercase)
|
||||
&& !raceDTO.boatClass.toUpperCase().contains(textAsUppercase)
|
||||
&& !raceDTO.name.toUpperCase().contains(textAsUppercase)) {
|
||||
&& !raceDTO.getName().toUpperCase().contains(textAsUppercase)) {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
@@ -484,7 +484,7 @@ public abstract class AbstractTrackedRacesListComposite extends SimplePanel impl
|
||||
for (RaceDTO race : raceList.getList()) {
|
||||
String regattaName = race.getRegattaName();
|
||||
if (regattaName.equals(raceIdentifier.getRegattaName())
|
||||
&& race.name.equals(raceIdentifier.getRaceName())) {
|
||||
&& race.getName().equals(raceIdentifier.getRaceName())) {
|
||||
dontFireNextSelectionChangeEvent = true;
|
||||
selectionModel.setSelected(race, true);
|
||||
break;
|
||||
|
||||
+6
-6
@@ -45,13 +45,13 @@ public class EventDialog extends DataEntryDialog<EventDTO> {
|
||||
@Override
|
||||
public String getErrorMessage(EventDTO eventToValidate) {
|
||||
String errorMessage = null;
|
||||
boolean nameNotEmpty = eventToValidate.name != null && eventToValidate.name.length() > 0;
|
||||
boolean venueNotEmpty = eventToValidate.venue.name != null && eventToValidate.venue.name.length() > 0;
|
||||
boolean nameNotEmpty = eventToValidate.getName() != null && eventToValidate.getName().length() > 0;
|
||||
boolean venueNotEmpty = eventToValidate.venue.getName() != null && eventToValidate.venue.getName().length() > 0;
|
||||
boolean courseAreaNotEmpty = eventToValidate.venue.getCourseAreas() != null && eventToValidate.venue.getCourseAreas().size() > 0;
|
||||
|
||||
if (courseAreaNotEmpty) {
|
||||
for (CourseAreaDTO courseArea : eventToValidate.venue.getCourseAreas()) {
|
||||
courseAreaNotEmpty = courseArea.name != null && courseArea.name.length() > 0;
|
||||
courseAreaNotEmpty = courseArea.getName() != null && courseArea.getName().length() > 0;
|
||||
if (!courseAreaNotEmpty)
|
||||
break;
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class EventDialog extends DataEntryDialog<EventDTO> {
|
||||
|
||||
boolean unique = true;
|
||||
for (EventDTO event : existingEvents) {
|
||||
if (event.name.equals(eventToValidate.name)) {
|
||||
if (event.getName().equals(eventToValidate.getName())) {
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
@@ -105,7 +105,7 @@ public class EventDialog extends DataEntryDialog<EventDTO> {
|
||||
|
||||
@Override
|
||||
protected EventDTO getResult() {
|
||||
this.event.name = nameEntryField.getText();
|
||||
this.event.setName(nameEntryField.getText());
|
||||
this.event.publicationUrl = publicationUrlEntryField.getText();
|
||||
this.event.isPublic = isPublicCheckBox.getValue();
|
||||
this.event.id = id;
|
||||
@@ -114,7 +114,7 @@ public class EventDialog extends DataEntryDialog<EventDTO> {
|
||||
int count = courseAreaNameEntryFields.size();
|
||||
for(int i = 0; i < count; i++) {
|
||||
CourseAreaDTO courseAreaDTO = new CourseAreaDTO();
|
||||
courseAreaDTO.name = courseAreaNameEntryFields.get(i).getValue();
|
||||
courseAreaDTO.setName(courseAreaNameEntryFields.get(i).getValue());
|
||||
courseAreas.add(courseAreaDTO);
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -12,9 +12,9 @@ public class EventEditDialog extends EventDialog {
|
||||
StringMessages stringConstants, DialogCallback<EventDTO> callback) {
|
||||
super(new EventParameterValidator(stringConstants, otherExistingEvents), stringConstants, callback);
|
||||
|
||||
nameEntryField = createTextBox(event.name);
|
||||
nameEntryField = createTextBox(event.getName());
|
||||
nameEntryField.setWidth("200px");
|
||||
venueEntryField = createTextBox(event.venue.name);
|
||||
venueEntryField = createTextBox(event.venue.getName());
|
||||
venueEntryField.setWidth("200px");
|
||||
publicationUrlEntryField = createTextBox(event.publicationUrl);
|
||||
publicationUrlEntryField.setWidth("200px");
|
||||
@@ -24,7 +24,7 @@ public class EventEditDialog extends EventDialog {
|
||||
|
||||
if (event.venue.getCourseAreas() != null && event.venue.getCourseAreas().size() > 0) {
|
||||
for (CourseAreaDTO courseArea : event.venue.getCourseAreas()) {
|
||||
addCourseAreaWidget(courseArea.name, false);
|
||||
addCourseAreaWidget(courseArea.getName(), false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+4
-4
@@ -109,7 +109,7 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
ListBox eventListBox = createListBox(false);
|
||||
eventListBox.addItem("Please select a sailing event...");
|
||||
for (EventDTO event: existingEvents) {
|
||||
eventListBox.addItem(event.name);
|
||||
eventListBox.addItem(event.getName());
|
||||
}
|
||||
eventListBox.addChangeHandler(new ChangeHandler() {
|
||||
@Override
|
||||
@@ -132,7 +132,7 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
private void fillCourseAreaListBox(EventDTO selectedEvent) {
|
||||
courseAreaListBox.addItem("Please select a course area...");
|
||||
for (CourseAreaDTO courseArea : selectedEvent.venue.getCourseAreas()) {
|
||||
courseAreaListBox.addItem(courseArea.name);
|
||||
courseAreaListBox.addItem(courseArea.getName());
|
||||
}
|
||||
courseAreaListBox.setEnabled(true);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
if(selIndex > 0) { // the zero index represents the 'no selection' text
|
||||
String itemText = sailingEventsListBox.getItemText(selIndex);
|
||||
for(EventDTO eventDTO: existingEvents) {
|
||||
if(eventDTO.name.equals(itemText)) {
|
||||
if(eventDTO.getName().equals(itemText)) {
|
||||
result = eventDTO;
|
||||
break;
|
||||
}
|
||||
@@ -159,7 +159,7 @@ public abstract class FlexibleLeaderboardDialog extends AbstractLeaderboardDialo
|
||||
if(selIndex > 0 && event != null) { // the zero index represents the 'no selection' text
|
||||
String itemText = courseAreaListBox.getItemText(selIndex);
|
||||
for(CourseAreaDTO courseAreaDTO: event.venue.getCourseAreas()) {
|
||||
if(courseAreaDTO.name.equals(itemText)) {
|
||||
if(courseAreaDTO.getName().equals(itemText)) {
|
||||
result = courseAreaDTO;
|
||||
break;
|
||||
}
|
||||
|
||||
+6
-6
@@ -400,7 +400,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
|
||||
TextColumn<Pair<RaceColumnDTO, FleetDTO>> fleetNameColumn = new TextColumn<Pair<RaceColumnDTO, FleetDTO>>() {
|
||||
@Override
|
||||
public String getValue(Pair<RaceColumnDTO, FleetDTO> object) {
|
||||
return object.getB().name;
|
||||
return object.getB().getName();
|
||||
}
|
||||
};
|
||||
TextColumn<Pair<RaceColumnDTO, FleetDTO>> explicitFactorColumn = new TextColumn<Pair<RaceColumnDTO, FleetDTO>>() {
|
||||
@@ -618,7 +618,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
|
||||
|
||||
private void unlinkRaceColumnFromTrackedRace(final String raceColumnName, final FleetDTO fleet) {
|
||||
final String selectedLeaderboardName = getSelectedLeaderboardName();
|
||||
sailingService.disconnectLeaderboardColumnFromTrackedRace(selectedLeaderboardName, raceColumnName, fleet.name,
|
||||
sailingService.disconnectLeaderboardColumnFromTrackedRace(selectedLeaderboardName, raceColumnName, fleet.getName(),
|
||||
new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
@@ -715,7 +715,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
|
||||
private void selectRaceColumn(String raceCoumnName) {
|
||||
List<Pair<RaceColumnDTO, FleetDTO>> list = raceColumnAndFleetList.getList();
|
||||
for (Pair<RaceColumnDTO, FleetDTO> pair : list) {
|
||||
if (pair.getA().name.equals(raceCoumnName)) {
|
||||
if (pair.getA().getName().equals(raceCoumnName)) {
|
||||
raceColumnTableSelectionModel.setSelected(pair, true);
|
||||
break;
|
||||
}
|
||||
@@ -726,7 +726,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
|
||||
final String selectedLeaderboardName = getSelectedLeaderboardName();
|
||||
final Pair<RaceColumnDTO, FleetDTO> selectedRaceColumnAndFleetNameInLeaderboard = getSelectedRaceColumnWithFleet();
|
||||
final String selectedRaceColumnName = selectedRaceColumnAndFleetNameInLeaderboard.getA().getRaceColumnName();
|
||||
final String selectedFleetName = selectedRaceColumnAndFleetNameInLeaderboard.getB().name;
|
||||
final String selectedFleetName = selectedRaceColumnAndFleetNameInLeaderboard.getB().getName();
|
||||
sailingService.getRegattaAndRaceNameOfTrackedRaceConnectedToLeaderboardColumn(selectedLeaderboardName,
|
||||
selectedRaceColumnName, new AsyncCallback<Map<String, RegattaAndRaceIdentifier>>() {
|
||||
@Override
|
||||
@@ -866,7 +866,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
|
||||
|
||||
for(RaceColumnDTO newRaceColumn: newRaceColumns) {
|
||||
if(!existingRaceColumns.contains(newRaceColumn)) {
|
||||
raceColumnsToAdd.add(new Pair<String, Boolean>(newRaceColumn.name, newRaceColumn.isMedalRace()));
|
||||
raceColumnsToAdd.add(new Pair<String, Boolean>(newRaceColumn.getName(), newRaceColumn.isMedalRace()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1088,7 +1088,7 @@ public class LeaderboardConfigPanel extends FormPanel implements SelectedLeaderb
|
||||
private void linkTrackedRaceToSelectedRaceColumn(final RaceColumnDTO selectedRaceInLeaderboard,
|
||||
final FleetDTO fleet, final RegattaAndRaceIdentifier selectedRace) {
|
||||
sailingService.connectTrackedRaceToLeaderboardColumn(getSelectedLeaderboardName(), selectedRaceInLeaderboard
|
||||
.getRaceColumnName(), fleet.name, selectedRace,
|
||||
.getRaceColumnName(), fleet.getName(), selectedRace,
|
||||
new AsyncCallback<Boolean>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
|
||||
+16
-16
@@ -413,17 +413,17 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
@Override
|
||||
public SafeHtml getValue(LeaderboardGroupDTO group) {
|
||||
String debugParam = Window.Location.getParameter("gwt.codesvr");
|
||||
String link = URLEncoder.encode("/gwt/Spectator.html?leaderboardGroupName=" + group.name
|
||||
String link = URLEncoder.encode("/gwt/Spectator.html?leaderboardGroupName=" + group.getName()
|
||||
+ "&showRaceDetails=true&"+RaceBoardViewConfiguration.PARAM_CAN_REPLAY_DURING_LIVE_RACES+"=true"
|
||||
+ (debugParam != null && !debugParam.isEmpty() ? "&gwt.codesvr=" + debugParam : ""));
|
||||
return ANCHORTEMPLATE.cell(link, group.name);
|
||||
return ANCHORTEMPLATE.cell(link, group.getName());
|
||||
}
|
||||
};
|
||||
groupNameColumn.setSortable(true);
|
||||
leaderboardGroupsListHandler.setComparator(groupNameColumn, new Comparator<LeaderboardGroupDTO>() {
|
||||
@Override
|
||||
public int compare(LeaderboardGroupDTO group1, LeaderboardGroupDTO group2) {
|
||||
return group1.name.compareTo(group2.name);
|
||||
return group1.getName().compareTo(group2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -450,7 +450,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
@Override
|
||||
public void update(int index, final LeaderboardGroupDTO group, String command) {
|
||||
if (command.equals(LeaderboardGroupConfigImagesBarCell.ACTION_EDIT)) {
|
||||
final String oldGroupName = group.name;
|
||||
final String oldGroupName = group.getName();
|
||||
ArrayList<LeaderboardGroupDTO> otherExistingGroups = new ArrayList<LeaderboardGroupDTO>(availableLeaderboardGroups);
|
||||
otherExistingGroups.remove(group);
|
||||
LeaderboardGroupEditDialog dialog = new LeaderboardGroupEditDialog(group, otherExistingGroups, stringMessages,
|
||||
@@ -464,7 +464,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
});
|
||||
dialog.show();
|
||||
} else if (command.equals(LeaderboardGroupConfigImagesBarCell.ACTION_REMOVE)) {
|
||||
if (Window.confirm("Do you really want to remove the leaderboard group: '" + group.name + "' ?")) {
|
||||
if (Window.confirm("Do you really want to remove the leaderboard group: '" + group.getName() + "' ?")) {
|
||||
removeLeaderboardGroup(group);
|
||||
}
|
||||
}
|
||||
@@ -609,8 +609,8 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
// Update the availableLeaderboardGroups and the list of displayed groups
|
||||
for (int i = 0; i < availableLeaderboardGroups.size(); i++) {
|
||||
LeaderboardGroupDTO group = availableLeaderboardGroups.get(i);
|
||||
if (oldGroupName.equals(group.name)) {
|
||||
groupToUpdate.name = updateDescriptor.getName();
|
||||
if (oldGroupName.equals(group.getName())) {
|
||||
groupToUpdate.setName(updateDescriptor.getName());
|
||||
groupToUpdate.description = updateDescriptor.getDescription();
|
||||
groupToUpdate.displayLeaderboardsInReverseOrder = updateDescriptor.isDisplayLeaderboardsInReverseOrder();
|
||||
groupToUpdate.setOverallLeaderboardDiscardThresholds(updateDescriptor.getOverallLeaderboardDiscardThresholds());
|
||||
@@ -635,12 +635,12 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
for (StrippedLeaderboardDTO leaderboardDTO : group.leaderboards) {
|
||||
leaderboardNames.add(leaderboardDTO.name);
|
||||
}
|
||||
sailingService.updateLeaderboardGroup(group.name, group.name, group.description,
|
||||
sailingService.updateLeaderboardGroup(group.getName(), group.getName(), group.description,
|
||||
leaderboardNames, group.getOverallLeaderboardDiscardThresholds(),
|
||||
group.getOverallLeaderboardScoringSchemeType(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to update leaderboard group " + group.name + ": "
|
||||
errorReporter.reportError("Error trying to update leaderboard group " + group.getName() + ": "
|
||||
+ t.getMessage());
|
||||
}
|
||||
@Override
|
||||
@@ -650,10 +650,10 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
}
|
||||
|
||||
private void removeLeaderboardGroup(final LeaderboardGroupDTO group) {
|
||||
sailingService.removeLeaderboardGroup(group.name, new AsyncCallback<Void>() {
|
||||
sailingService.removeLeaderboardGroup(group.getName(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to remove leaderboard group " + group.name + ": "
|
||||
errorReporter.reportError("Error trying to remove leaderboard group " + group.getName() + ": "
|
||||
+ t.getMessage());
|
||||
}
|
||||
@Override
|
||||
@@ -663,7 +663,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
|
||||
//Check if the removed group was the selected one
|
||||
LeaderboardGroupDTO selectedGroup = groupsSelectionModel.getSelectedObject();
|
||||
if (selectedGroup != null && selectedGroup.name.equals(group.name)) {
|
||||
if (selectedGroup != null && selectedGroup.getName().equals(group.getName())) {
|
||||
groupsSelectionModel.setSelected(null, true);
|
||||
}
|
||||
}
|
||||
@@ -674,7 +674,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
List<String> filter = Arrays.asList(groupsFilterTextBox.getText().split("\\s"));
|
||||
groupsProvider.getList().clear();
|
||||
for (LeaderboardGroupDTO group : availableLeaderboardGroups) {
|
||||
if (textContainsStringsToCheck(filter, group.name)) {
|
||||
if (textContainsStringsToCheck(filter, group.getName())) {
|
||||
groupsProvider.getList().add(group);
|
||||
}
|
||||
}
|
||||
@@ -686,10 +686,10 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
final LeaderboardGroupDTO selectedGroup = groupsSelectionModel.getSelectedObject();
|
||||
splitPanel.setVisible(selectedGroup != null);
|
||||
if (selectedGroup != null) {
|
||||
sailingService.getLeaderboardGroupByName(selectedGroup.name, false /*withGeoLocationData*/, new AsyncCallback<LeaderboardGroupDTO>() {
|
||||
sailingService.getLeaderboardGroupByName(selectedGroup.getName(), false /*withGeoLocationData*/, new AsyncCallback<LeaderboardGroupDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to obtain the leaderboard group " + selectedGroup.name + ": " + t.getMessage());
|
||||
errorReporter.reportError("Error trying to obtain the leaderboard group " + selectedGroup.getName() + ": " + t.getMessage());
|
||||
}
|
||||
@Override
|
||||
public void onSuccess(LeaderboardGroupDTO result) {
|
||||
@@ -698,7 +698,7 @@ public class LeaderboardGroupConfigPanel extends AbstractRegattaPanel {
|
||||
groupsSelectionModel.setSelected(result, true);
|
||||
|
||||
//Display details of the group
|
||||
groupDetailsCaptionPanel.setCaptionText(stringMessages.detailsOfLeaderboardGroup() + " '" + result.name + "'");
|
||||
groupDetailsCaptionPanel.setCaptionText(stringMessages.detailsOfLeaderboardGroup() + " '" + result.getName() + "'");
|
||||
descriptionTextArea.setText(result.description);
|
||||
setDescriptionEditable(false);
|
||||
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public class LeaderboardGroupDialog extends DataEntryDialog<LeaderboardGroupDial
|
||||
|
||||
boolean unique = true;
|
||||
for (LeaderboardGroupDTO group : existingGroups) {
|
||||
if (group.name.equals(groupToValidate.getName())) {
|
||||
if (group.getName().equals(groupToValidate.getName())) {
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@ public class LeaderboardGroupEditDialog extends LeaderboardGroupDialog {
|
||||
super(group, stringMessages, callback, otherExistingGroups);
|
||||
// don't allow editing the overall leaderboard's scoring scheme if the group already uses an overall leaderboard
|
||||
getOverallLeaderboardScoringSchemeListBox().setEnabled(!group.hasOverallLeaderboard());
|
||||
nameEntryField = createTextBox(group.name, 50);
|
||||
nameEntryField = createTextBox(group.getName(), 50);
|
||||
descriptionEntryField = createTextArea(group.description);
|
||||
displayLeaderboardsInReverseOrderCheckBox.setValue(group.displayLeaderboardsInReverseOrder);
|
||||
displayLeaderboardsInReverseOrderCheckBox.setEnabled(false);
|
||||
|
||||
+13
-3
@@ -21,8 +21,9 @@ import com.google.gwt.view.client.DefaultSelectionEventManager;
|
||||
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.media.MediaTrack;
|
||||
import com.sap.sailing.domain.common.media.MediaUtil;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialog.DialogCallback;
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack;
|
||||
import com.sap.sailing.gwt.ui.client.ErrorReporter;
|
||||
import com.sap.sailing.gwt.ui.client.MediaServiceAsync;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
@@ -218,13 +219,22 @@ public class MediaPanel extends FlowPanel {
|
||||
startTimeColumn.setSortable(true);
|
||||
sortHandler.setComparator(startTimeColumn, new Comparator<MediaTrack>() {
|
||||
public int compare(MediaTrack mediaTrack1, MediaTrack mediaTrack2) {
|
||||
return mediaTrack1.startTime.compareTo(mediaTrack2.startTime);
|
||||
return MediaUtil.compareDatesAllowingNull(mediaTrack1.startTime, mediaTrack2.startTime);
|
||||
}
|
||||
});
|
||||
startTimeColumn.setFieldUpdater(new FieldUpdater<MediaTrack, String>() {
|
||||
public void update(int index, MediaTrack mediaTrack, String newStartTime) {
|
||||
// Called when the user changes the value.
|
||||
mediaTrack.startTime = TimeFormatUtil.DATETIME_FORMAT.parse(newStartTime);
|
||||
newStartTime = newStartTime.trim();
|
||||
if ("".equals(newStartTime)) {
|
||||
mediaTrack.startTime = null;
|
||||
} else {
|
||||
try {
|
||||
mediaTrack.startTime = TimeFormatUtil.DATETIME_FORMAT.parse(newStartTime);
|
||||
} catch (IllegalArgumentException e) {
|
||||
errorReporter.reportError(stringMessages.mediaDateFormatError(TimeFormatUtil.DATETIME_FORMAT.toString()));
|
||||
}
|
||||
}
|
||||
mediaService.updateStartTime(mediaTrack, new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
|
||||
+2
-2
@@ -12,10 +12,10 @@ import com.google.gwt.user.client.ui.Label;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.media.MediaTrack;
|
||||
import com.sap.sailing.domain.common.media.MediaTrack.MimeType;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialog;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack;
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack.MimeType;
|
||||
|
||||
public class MediaTrackDialog extends DataEntryDialog<MediaTrack> {
|
||||
|
||||
|
||||
+2
-2
@@ -10,10 +10,10 @@ import com.google.gwt.user.client.ui.TextArea;
|
||||
import com.google.gwt.user.client.ui.TextBox;
|
||||
import com.google.gwt.user.client.ui.VerticalPanel;
|
||||
import com.google.gwt.user.client.ui.Widget;
|
||||
import com.sap.sailing.domain.common.media.MediaTrack;
|
||||
import com.sap.sailing.domain.common.media.MediaTrack.MimeType;
|
||||
import com.sap.sailing.gwt.ui.client.DataEntryDialog;
|
||||
import com.sap.sailing.gwt.ui.client.StringMessages;
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack;
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack.MimeType;
|
||||
|
||||
public class MediaTrackYoutubeDialog extends DataEntryDialog<MediaTrack> {
|
||||
|
||||
|
||||
+3
-3
@@ -45,7 +45,7 @@ public class RaceColumnsInLeaderboardDialog extends DataEntryDialog<List<RaceCol
|
||||
int index = 0;
|
||||
boolean raceColumnNameNotEmpty = true;
|
||||
for (RaceColumnDTO raceColumn : raceColumnsWithFleetToValidate) {
|
||||
raceColumnNameNotEmpty = raceColumn.name != null && raceColumn.name.length() > 0;
|
||||
raceColumnNameNotEmpty = raceColumn.getName() != null && raceColumn.getName().length() > 0;
|
||||
if (!raceColumnNameNotEmpty) {
|
||||
break;
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class RaceColumnsInLeaderboardDialog extends DataEntryDialog<List<RaceCol
|
||||
boolean raceColumnUnique = true;
|
||||
HashSet<String> setToFindDuplicates = new HashSet<String>();
|
||||
for (RaceColumnDTO raceColumn : raceColumnsWithFleetToValidate) {
|
||||
if (!setToFindDuplicates.add(raceColumn.name)) {
|
||||
if (!setToFindDuplicates.add(raceColumn.getName())) {
|
||||
raceColumnUnique = false;
|
||||
break;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class RaceColumnsInLeaderboardDialog extends DataEntryDialog<List<RaceCol
|
||||
for(int i = 0; i < racesCount; i++) {
|
||||
String raceColumnName = raceNameEntryFields.get(i).getValue();
|
||||
RaceColumnDTO raceColumnDTO = new RaceColumnDTO(/* isValidInTotalScore not relevant here because no scores attached */ null);
|
||||
raceColumnDTO.name = raceColumnName;
|
||||
raceColumnDTO.setName(raceColumnName);
|
||||
raceColumnDTO.setMedalRace(isMedalRaceCheckboxes.get(i).getValue());
|
||||
racesWithFleet.add(raceColumnDTO);
|
||||
}
|
||||
|
||||
+12
-12
@@ -135,14 +135,14 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
MarkDTO left;
|
||||
MarkDTO right;
|
||||
String gateName;
|
||||
if (first.name.matches("^.*"+REGEX_FOR_LEFT+".*$")) {
|
||||
if (first.getName().matches("^.*"+REGEX_FOR_LEFT+".*$")) {
|
||||
left = first;
|
||||
right = second;
|
||||
} else {
|
||||
left = second;
|
||||
right = first;
|
||||
}
|
||||
gateName = left.name.replaceFirst(REGEX_FOR_LEFT, "");
|
||||
gateName = left.getName().replaceFirst(REGEX_FOR_LEFT, "");
|
||||
result = new GateDTO(/* generate UUID on the server */ null, gateName, left, right);
|
||||
}
|
||||
return result;
|
||||
@@ -222,7 +222,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
TextColumn<ControlPointAndOldAndNewMark> nameColumn = new TextColumn<ControlPointAndOldAndNewMark>() {
|
||||
@Override
|
||||
public String getValue(ControlPointAndOldAndNewMark cpaoanb) {
|
||||
return cpaoanb.getControlPoint().name;
|
||||
return cpaoanb.getControlPoint().getName();
|
||||
}
|
||||
};
|
||||
controlPointsTable.addColumn(nameColumn, stringMessages.controlPoint());
|
||||
@@ -240,14 +240,14 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
TextColumn<ControlPointAndOldAndNewMark> oldMarkColumn = new TextColumn<ControlPointAndOldAndNewMark>() {
|
||||
@Override
|
||||
public String getValue(ControlPointAndOldAndNewMark cpaoanb) {
|
||||
return "" + cpaoanb.getOldMark().name;
|
||||
return "" + cpaoanb.getOldMark().getName();
|
||||
}
|
||||
};
|
||||
controlPointsTable.addColumn(oldMarkColumn, stringMessages.mark());
|
||||
TextColumn<ControlPointAndOldAndNewMark> newMarkColumn = new TextColumn<ControlPointAndOldAndNewMark>() {
|
||||
@Override
|
||||
public String getValue(ControlPointAndOldAndNewMark cpaoanb) {
|
||||
return "" + cpaoanb.getNewMark().name;
|
||||
return "" + cpaoanb.getNewMark().getName();
|
||||
}
|
||||
};
|
||||
controlPointsTable.addColumn(newMarkColumn, stringMessages.newMark());
|
||||
@@ -333,7 +333,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
MarkDTO newMark = controlPointsSelectionModel.getSelectedSet().iterator().next().getNewMark();
|
||||
if (newMark != null) {
|
||||
for (MarkDTO markDTO : markDataProvider.getList()) {
|
||||
if (markDTO.name.equals(newMark.name)) {
|
||||
if (markDTO.getName().equals(newMark.getName())) {
|
||||
markSelectionModel.setSelected(markDTO, true);
|
||||
}
|
||||
}
|
||||
@@ -387,7 +387,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
for (ControlPointAndOldAndNewMark cpaoanb : controlPointDataProvider.getList()) {
|
||||
if (cpaoanb.getControlPoint() == oldGate) {
|
||||
MarkDTO newMark = cpaoanb.getNewMark();
|
||||
if (newRight != null || newMark.name.matches("^.*"+REGEX_FOR_LEFT+".*$")) {
|
||||
if (newRight != null || newMark.getName().matches("^.*"+REGEX_FOR_LEFT+".*$")) {
|
||||
newLeft = newMark;
|
||||
} else {
|
||||
newRight = newMark;
|
||||
@@ -396,7 +396,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
}
|
||||
assert newLeft != null && newRight != null;
|
||||
// if old gate had null ID, the new gate will have a null ID too, causing the server to generate one
|
||||
return new GateDTO(oldGate.getIdAsString(), oldGate.name, newLeft, newRight);
|
||||
return new GateDTO(oldGate.getIdAsString(), oldGate.getName(), newLeft, newRight);
|
||||
}
|
||||
|
||||
private CellTable<MarkDTO> createAvailableMarksTable(final StringMessages stringMessages, AdminConsoleTableResources tableRes,
|
||||
@@ -406,7 +406,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
TextColumn<MarkDTO> markNameColumn = new TextColumn<MarkDTO>() {
|
||||
@Override
|
||||
public String getValue(MarkDTO markDTO) {
|
||||
return markDTO.name;
|
||||
return markDTO.getName();
|
||||
}
|
||||
};
|
||||
result.addColumn(markNameColumn, stringMessages.mark());
|
||||
@@ -460,7 +460,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
} else {
|
||||
w.setNewMark(selectedNewMark);
|
||||
}
|
||||
if (w.getOldMark().name.equals(w.getNewMark().name)) {
|
||||
if (w.getOldMark().getName().equals(w.getNewMark().getName())) {
|
||||
checkIfAllMarksOfControlPointAreUnchangedAndIfSoRememberThis(w.getControlPoint());
|
||||
} else {
|
||||
controlPointsNeedingReplacement.add(w.getControlPoint());
|
||||
@@ -477,7 +477,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
boolean allMarksUnchanged = true;
|
||||
for (ControlPointAndOldAndNewMark cpaoanb : controlPointDataProvider.getList()) {
|
||||
if (cpaoanb.getControlPoint() == controlPoint) {
|
||||
if (!cpaoanb.getOldMark().name.equals(cpaoanb.getNewMark().name)) {
|
||||
if (!cpaoanb.getOldMark().getName().equals(cpaoanb.getNewMark().getName())) {
|
||||
allMarksUnchanged = false;
|
||||
break;
|
||||
}
|
||||
@@ -549,7 +549,7 @@ public class RaceCourseManagementPanel extends AbstractRaceManagementPanel {
|
||||
Collections.sort(markDataProvider.getList(), new Comparator<MarkDTO>() {
|
||||
@Override
|
||||
public int compare(MarkDTO o1, MarkDTO o2) {
|
||||
return o1.name.compareTo(o2.name);
|
||||
return o1.getName().compareTo(o2.getName());
|
||||
}
|
||||
});
|
||||
for (ControlPointAndOldAndNewMark w : controlPointsSelectionModel.getSelectedSet()) {
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class RacesListBoxPanel extends FormPanel implements RegattaDisplayer, Ra
|
||||
}
|
||||
|
||||
private String toString(RaceDTO race) {
|
||||
return race.getRegattaName()+" - "+race.name+(race.isTracked ? " ("+stringConstants.tracked()+")" : "");
|
||||
return race.getRegattaName()+" - "+race.getName()+(race.isTracked ? " ("+stringConstants.tracked()+")" : "");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
-13
@@ -101,7 +101,7 @@ public class RegattaDetailsComposite extends Composite {
|
||||
TextColumn<SeriesDTO> seriesNameColumn = new TextColumn<SeriesDTO>() {
|
||||
@Override
|
||||
public String getValue(SeriesDTO series) {
|
||||
return series.name;
|
||||
return series.getName();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -147,7 +147,7 @@ public class RegattaDetailsComposite extends Composite {
|
||||
int fleetsCount = series.getFleets().size();
|
||||
int i = 1;
|
||||
for(FleetDTO fleet: series.getFleets()) {
|
||||
result += fleet.name;
|
||||
result += fleet.getName();
|
||||
result += "(" + fleet.getOrderNo() + ") ";
|
||||
if (i < fleetsCount) {
|
||||
result += ", ";
|
||||
@@ -237,26 +237,26 @@ public class RegattaDetailsComposite extends Composite {
|
||||
final boolean isStartsWithZeroScoreChanged = series.isStartsWithZeroScore() != seriesDescriptor.isStartsWithZeroScore();
|
||||
final boolean seriesResultDiscardingThresholdsChanged = !Arrays.equals(series.getDiscardThresholds(),
|
||||
seriesDescriptor.getResultDiscardingThresholds());
|
||||
final RegattaIdentifier regattaIdentifier = new RegattaName(regatta.name);
|
||||
final RegattaIdentifier regattaIdentifier = new RegattaName(regatta.getName());
|
||||
List<RaceColumnDTO> existingRaceColumns = series.getRaceColumns();
|
||||
final List<String> raceColumnsToAdd = new ArrayList<String>();
|
||||
final List<String> raceColumnsToRemove = new ArrayList<String>();
|
||||
|
||||
for (RaceColumnDTO newRaceColumn : newRaceColumns) {
|
||||
if (!existingRaceColumns.contains(newRaceColumn)) {
|
||||
raceColumnsToAdd.add(newRaceColumn.name);
|
||||
raceColumnsToAdd.add(newRaceColumn.getName());
|
||||
}
|
||||
}
|
||||
for (RaceColumnDTO existingRaceColumn : existingRaceColumns) {
|
||||
if (!newRaceColumns.contains(existingRaceColumn)) {
|
||||
raceColumnsToRemove.add(existingRaceColumn.name);
|
||||
raceColumnsToRemove.add(existingRaceColumn.getName());
|
||||
}
|
||||
}
|
||||
sailingService.addRaceColumnsToSeries(regattaIdentifier, series.name, raceColumnsToAdd, new AsyncCallback<List<RaceColumnInSeriesDTO>>() {
|
||||
sailingService.addRaceColumnsToSeries(regattaIdentifier, series.getName(), raceColumnsToAdd, new AsyncCallback<List<RaceColumnInSeriesDTO>>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to add race columns "
|
||||
+ raceColumnsToAdd + " to series " + series.name
|
||||
+ raceColumnsToAdd + " to series " + series.getName()
|
||||
+ ": " + caught.getMessage());
|
||||
|
||||
}
|
||||
@@ -267,11 +267,11 @@ public class RegattaDetailsComposite extends Composite {
|
||||
}
|
||||
});
|
||||
|
||||
sailingService.removeRaceColumnsFromSeries(regattaIdentifier, series.name, raceColumnsToRemove, new AsyncCallback<Void>() {
|
||||
sailingService.removeRaceColumnsFromSeries(regattaIdentifier, series.getName(), raceColumnsToRemove, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to remove race columns "
|
||||
+ raceColumnsToAdd + " from series " + series.name
|
||||
+ raceColumnsToAdd + " from series " + series.getName()
|
||||
+ ": " + caught.getMessage());
|
||||
}
|
||||
|
||||
@@ -281,13 +281,13 @@ public class RegattaDetailsComposite extends Composite {
|
||||
}
|
||||
});
|
||||
if (isMedalChanged || seriesResultDiscardingThresholdsChanged || isStartsWithZeroScoreChanged) {
|
||||
sailingService.updateSeries(regattaIdentifier, series.name, seriesDescriptor.isMedal(),
|
||||
sailingService.updateSeries(regattaIdentifier, series.getName(), seriesDescriptor.isMedal(),
|
||||
seriesDescriptor.getResultDiscardingThresholds(), seriesDescriptor.isStartsWithZeroScore(),
|
||||
new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to remove race columns "
|
||||
+ raceColumnsToAdd + " from series " + series.name
|
||||
+ raceColumnsToAdd + " from series " + series.getName()
|
||||
+ ": " + caught.getMessage());
|
||||
}
|
||||
|
||||
@@ -301,8 +301,8 @@ public class RegattaDetailsComposite extends Composite {
|
||||
|
||||
private void updateRegattaDetails() {
|
||||
if (regatta != null) {
|
||||
regattaName.setText(regatta.name);
|
||||
boatClassName.setText(regatta.boatClass != null ? regatta.boatClass.name : "");
|
||||
regattaName.setText(regatta.getName());
|
||||
boatClassName.setText(regatta.boatClass != null ? regatta.boatClass.getName() : "");
|
||||
defaultCourseArea.setText(regatta.defaultCourseAreaIdAsString == null ? "" : regatta.defaultCourseAreaName);
|
||||
ScoringSchemeType scoringScheme = regatta.scoringScheme;
|
||||
String scoringSystemText = scoringScheme == null ? "" : ScoringSchemeTypeFormatter.format(scoringScheme, stringMessages);
|
||||
|
||||
+3
-3
@@ -83,7 +83,7 @@ public abstract class RegattaLeaderboardDialog extends AbstractLeaderboardDialog
|
||||
// sort the regatta names
|
||||
List<String> sortedRegattaNames = new ArrayList<String>();
|
||||
for (RegattaDTO regatta : existingRegattas) {
|
||||
sortedRegattaNames.add(regatta.name);
|
||||
sortedRegattaNames.add(regatta.getName());
|
||||
}
|
||||
Collections.sort(sortedRegattaNames);
|
||||
|
||||
@@ -102,7 +102,7 @@ public abstract class RegattaLeaderboardDialog extends AbstractLeaderboardDialog
|
||||
@Override
|
||||
protected LeaderboardDescriptor getResult() {
|
||||
LeaderboardDescriptor leaderboard = super.getResult();
|
||||
leaderboard.setRegattaName(getSelectedRegatta() != null ? getSelectedRegatta().name : null);
|
||||
leaderboard.setRegattaName(getSelectedRegatta() != null ? getSelectedRegatta().getName() : null);
|
||||
return leaderboard;
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public abstract class RegattaLeaderboardDialog extends AbstractLeaderboardDialog
|
||||
if (selIndex > 0) { // the zero index represents the 'no selection' text
|
||||
String itemText = regattaListBox.getItemText(selIndex);
|
||||
for (RegattaDTO regattaDTO : existingRegattas) {
|
||||
if (regattaDTO.name.equals(itemText)) {
|
||||
if (regattaDTO.getName().equals(itemText)) {
|
||||
result = regattaDTO;
|
||||
break;
|
||||
}
|
||||
|
||||
+12
-12
@@ -138,28 +138,28 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
TextColumn<RegattaDTO> regattaNameColumn = new TextColumn<RegattaDTO>() {
|
||||
@Override
|
||||
public String getValue(RegattaDTO regatta) {
|
||||
return regatta.name;
|
||||
return regatta.getName();
|
||||
}
|
||||
};
|
||||
regattaNameColumn.setSortable(true);
|
||||
columnSortHandler.setComparator(regattaNameColumn, new Comparator<RegattaDTO>() {
|
||||
@Override
|
||||
public int compare(RegattaDTO r1, RegattaDTO r2) {
|
||||
return r1.name.compareTo(r2.name);
|
||||
return r1.getName().compareTo(r2.getName());
|
||||
}
|
||||
});
|
||||
|
||||
TextColumn<RegattaDTO> regattaBoatClassColumn = new TextColumn<RegattaDTO>() {
|
||||
@Override
|
||||
public String getValue(RegattaDTO regatta) {
|
||||
return regatta.boatClass != null ? regatta.boatClass.name : "";
|
||||
return regatta.boatClass != null ? regatta.boatClass.getName() : "";
|
||||
}
|
||||
};
|
||||
regattaBoatClassColumn.setSortable(true);
|
||||
columnSortHandler.setComparator(regattaBoatClassColumn, new Comparator<RegattaDTO>() {
|
||||
@Override
|
||||
public int compare(RegattaDTO r1, RegattaDTO r2) {
|
||||
return r1.boatClass.name.compareTo(r2.boatClass.name);
|
||||
return r1.boatClass.getName().compareTo(r2.boatClass.getName());
|
||||
}
|
||||
});
|
||||
|
||||
@@ -171,7 +171,7 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
if (RegattaConfigImagesBarCell.ACTION_EDIT.equals(value)) {
|
||||
editRegatta(regatta);
|
||||
} else if (RegattaConfigImagesBarCell.ACTION_REMOVE.equals(value)) {
|
||||
if (Window.confirm(stringMessages.doYouReallyWantToRemoveRegatta(regatta.name))) {
|
||||
if (Window.confirm(stringMessages.doYouReallyWantToRemoveRegatta(regatta.getName()))) {
|
||||
removeRegatta(regatta);
|
||||
}
|
||||
}
|
||||
@@ -194,9 +194,9 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
boolean failed = false;
|
||||
for (String word : wordsToFilter) {
|
||||
String textAsUppercase = word.toUpperCase().trim();
|
||||
if (!regattaDTO.name.toUpperCase().contains(textAsUppercase)
|
||||
&& (regattaDTO.boatClass == null || !regattaDTO.boatClass.name.toUpperCase().contains(
|
||||
textAsUppercase)) && !regattaDTO.name.toUpperCase().contains(textAsUppercase)) {
|
||||
if (!regattaDTO.getName().toUpperCase().contains(textAsUppercase)
|
||||
&& (regattaDTO.boatClass == null || !regattaDTO.boatClass.getName().toUpperCase().contains(
|
||||
textAsUppercase)) && !regattaDTO.getName().toUpperCase().contains(textAsUppercase)) {
|
||||
failed = true;
|
||||
break;
|
||||
}
|
||||
@@ -215,11 +215,11 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
}
|
||||
|
||||
private void removeRegatta(final RegattaDTO regatta) {
|
||||
final RegattaIdentifier regattaIdentifier = new RegattaName(regatta.name);
|
||||
final RegattaIdentifier regattaIdentifier = new RegattaName(regatta.getName());
|
||||
sailingService.removeRegatta(regattaIdentifier, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to remove regatta " + regatta.name + ": " + caught.getMessage());
|
||||
errorReporter.reportError("Error trying to remove regatta " + regatta.getName() + ": " + caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -260,12 +260,12 @@ public class RegattaListComposite extends Composite implements RegattaDisplayer
|
||||
}
|
||||
|
||||
private void commitEditedRegatta(final RegattaDTO editedRegatta) {
|
||||
final RegattaIdentifier regattaName = new RegattaName(editedRegatta.name);
|
||||
final RegattaIdentifier regattaName = new RegattaName(editedRegatta.getName());
|
||||
|
||||
sailingService.updateRegatta(regattaName, editedRegatta.defaultCourseAreaIdAsString, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to update regatta " + editedRegatta.name + ": " + caught.getMessage());
|
||||
errorReporter.reportError("Error trying to update regatta " + editedRegatta.getName() + ": " + caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-4
@@ -123,19 +123,19 @@ public class RegattaStructureManagementPanel extends SimplePanel implements Rega
|
||||
for (SeriesDTO seriesDTO : newRegatta.series) {
|
||||
List<Triple<String, Integer, Color>> fleets = new ArrayList<Triple<String, Integer, Color>>();
|
||||
for(FleetDTO fleetDTO : seriesDTO.getFleets()) {
|
||||
Triple<String, Integer, Color> fleetTriple = new Triple<String, Integer, Color>(fleetDTO.name, fleetDTO.getOrderNo(), fleetDTO.getColor());
|
||||
Triple<String, Integer, Color> fleetTriple = new Triple<String, Integer, Color>(fleetDTO.getName(), fleetDTO.getOrderNo(), fleetDTO.getColor());
|
||||
fleets.add(fleetTriple);
|
||||
}
|
||||
Triple<List<Triple<String, Integer, Color>>, Pair<Boolean, Boolean>, int[]> seriesPair =
|
||||
new Triple<List<Triple<String, Integer, Color>>, Pair<Boolean, Boolean>, int[]>(
|
||||
fleets, new Pair<Boolean, Boolean>(seriesDTO.isMedal(), seriesDTO.isStartsWithZeroScore()), seriesDTO.getDiscardThresholds());
|
||||
seriesStructure.put(seriesDTO.name, seriesPair);
|
||||
seriesStructure.put(seriesDTO.getName(), seriesPair);
|
||||
}
|
||||
sailingService.createRegatta(newRegatta.name, newRegatta.boatClass==null?null:newRegatta.boatClass.name, seriesStructure, true,
|
||||
sailingService.createRegatta(newRegatta.getName(), newRegatta.boatClass==null?null:newRegatta.boatClass.getName(), seriesStructure, true,
|
||||
newRegatta.scoringScheme, newRegatta.defaultCourseAreaIdAsString, new AsyncCallback<RegattaDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to create new regatta " + newRegatta.name + ": " + t.getMessage());
|
||||
errorReporter.reportError("Error trying to create new regatta " + newRegatta.getName() + ": " + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-6
@@ -35,13 +35,13 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAnd
|
||||
@Override
|
||||
public String getErrorMessage(RegattaDTO regattaToValidate) {
|
||||
String errorMessage = null;
|
||||
boolean nameNotEmpty = regattaToValidate.name != null && regattaToValidate.name.length() > 0;
|
||||
boolean nameNotEmpty = regattaToValidate.getName() != null && regattaToValidate.getName().length() > 0;
|
||||
boolean boatClassNotEmpty = regattaToValidate.boatClass != null
|
||||
&& regattaToValidate.boatClass.name.length() > 0;
|
||||
&& regattaToValidate.boatClass.getName().length() > 0;
|
||||
|
||||
boolean unique = true;
|
||||
for (RegattaDTO regatta : existingRegattas) {
|
||||
if (regatta.name.equals(regattaToValidate.name)) {
|
||||
if (regatta.getName().equals(regattaToValidate.getName())) {
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAnd
|
||||
boolean seriesNameNotEmpty = true;
|
||||
|
||||
for (SeriesDTO series : seriesToValidate) {
|
||||
seriesNameNotEmpty = series.name != null && series.name.length() > 0;
|
||||
seriesNameNotEmpty = series.getName() != null && series.getName().length() > 0;
|
||||
if (!seriesNameNotEmpty) {
|
||||
break;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAnd
|
||||
|
||||
HashSet<String> setToFindDuplicates = new HashSet<String>();
|
||||
for (SeriesDTO series : seriesToValidate) {
|
||||
if (!setToFindDuplicates.add(series.name)) {
|
||||
if (!setToFindDuplicates.add(series.getName())) {
|
||||
seriesUnique = false;
|
||||
break;
|
||||
}
|
||||
@@ -143,7 +143,7 @@ public class RegattaWithSeriesAndFleetsCreateDialog extends RegattaWithSeriesAnd
|
||||
seriesLabel.setWordWrap(false);
|
||||
seriesLabel.getElement().getStyle().setFontWeight(FontWeight.BOLD);
|
||||
seriesGrid.setWidget(i * 2, 0, seriesLabel);
|
||||
seriesGrid.setHTML(i * 2, 1, seriesDTO.name);
|
||||
seriesGrid.setHTML(i * 2, 1, seriesDTO.getName());
|
||||
if (seriesDTO.getFleets() != null && seriesDTO.getFleets().size() > 0) {
|
||||
seriesGrid.setHTML(i * 2 + 1, 1, seriesDTO.getFleets().size() + " fleets: "
|
||||
+ seriesDTO.getFleets().toString());
|
||||
|
||||
+8
-8
@@ -50,12 +50,12 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
|
||||
nameEntryField = createTextBox(null);
|
||||
nameEntryField.setVisibleLength(40);
|
||||
nameEntryField.setText(regatta.name);
|
||||
nameEntryField.setText(regatta.getName());
|
||||
|
||||
boatClassEntryField = createTextBox(null);
|
||||
boatClassEntryField.setVisibleLength(20);
|
||||
if (regatta.boatClass != null) {
|
||||
boatClassEntryField.setText(regatta.boatClass.name);
|
||||
boatClassEntryField.setText(regatta.boatClass.getName());
|
||||
}
|
||||
|
||||
scoringSchemeListBox = createListBox(false);
|
||||
@@ -99,7 +99,7 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
|
||||
@Override
|
||||
protected RegattaDTO getResult() {
|
||||
regatta.name = nameEntryField.getText();
|
||||
regatta.setName(nameEntryField.getText());
|
||||
regatta.boatClass = new BoatClassDTO(boatClassEntryField.getText(), 0.0);
|
||||
regatta.scoringScheme = getSelectedScoringSchemeType();
|
||||
regatta.series = new ArrayList<SeriesDTO>();
|
||||
@@ -114,7 +114,7 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
regatta.defaultCourseAreaIdAsString = null;
|
||||
} else {
|
||||
regatta.defaultCourseAreaIdAsString = courseArea.id;
|
||||
regatta.defaultCourseAreaName = courseArea.name;
|
||||
regatta.defaultCourseAreaName = courseArea.getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
private void setupEventAndCourseAreaListBoxes(StringMessages stringConstants) {
|
||||
sailingEventsListBox.addItem(stringConstants.selectSailingEvent());
|
||||
for (EventDTO event : existingEvents) {
|
||||
sailingEventsListBox.addItem(event.name);
|
||||
sailingEventsListBox.addItem(event.getName());
|
||||
if (isCourseAreaInEvent(event, regatta.defaultCourseAreaIdAsString)) {
|
||||
sailingEventsListBox.setSelectedIndex(sailingEventsListBox.getItemCount() - 1);
|
||||
fillCourseAreaListBox(event);
|
||||
@@ -167,7 +167,7 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
private void fillCourseAreaListBox(EventDTO selectedEvent) {
|
||||
courseAreaListBox.addItem(stringMessages.selectCourseArea());
|
||||
for (CourseAreaDTO courseArea : selectedEvent.venue.getCourseAreas()) {
|
||||
courseAreaListBox.addItem(courseArea.name);
|
||||
courseAreaListBox.addItem(courseArea.getName());
|
||||
if (courseArea.id == regatta.defaultCourseAreaIdAsString) {
|
||||
courseAreaListBox.setSelectedIndex(courseAreaListBox.getItemCount() - 1);
|
||||
}
|
||||
@@ -181,7 +181,7 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
if (selIndex > 0) { // the zero index represents the 'no selection' text
|
||||
String itemText = sailingEventsListBox.getItemText(selIndex);
|
||||
for (EventDTO eventDTO : existingEvents) {
|
||||
if (eventDTO.name.equals(itemText)) {
|
||||
if (eventDTO.getName().equals(itemText)) {
|
||||
result = eventDTO;
|
||||
break;
|
||||
}
|
||||
@@ -197,7 +197,7 @@ public abstract class RegattaWithSeriesAndFleetsDialog extends DataEntryDialog<R
|
||||
if (selIndex > 0 && event != null) { // the zero index represents the 'no selection' text
|
||||
String itemText = courseAreaListBox.getItemText(selIndex);
|
||||
for (CourseAreaDTO courseAreaDTO : event.venue.getCourseAreas()) {
|
||||
if (courseAreaDTO.name.equals(itemText)) {
|
||||
if (courseAreaDTO.getName().equals(itemText)) {
|
||||
result = courseAreaDTO;
|
||||
break;
|
||||
}
|
||||
|
||||
+18
-18
@@ -96,14 +96,14 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
String debugParam = Window.Location.getParameter("gwt.codesvr");
|
||||
String link = URLEncoder.encode("/gwt/RegattaOverview.html?event=" + event.id
|
||||
+ (debugParam != null && !debugParam.isEmpty() ? "&gwt.codesvr=" + debugParam : ""));
|
||||
return ANCHORTEMPLATE.cell(link, event.name);
|
||||
return ANCHORTEMPLATE.cell(link, event.getName());
|
||||
}
|
||||
};
|
||||
|
||||
TextColumn<EventDTO> venueNameColumn = new TextColumn<EventDTO>() {
|
||||
@Override
|
||||
public String getValue(EventDTO event) {
|
||||
return event.venue != null ? event.venue.name : "";
|
||||
return event.venue != null ? event.venue.getName() : "";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -129,7 +129,7 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
int courseAreasCount = event.venue.getCourseAreas().size();
|
||||
int i = 1;
|
||||
for (CourseAreaDTO courseArea : event.venue.getCourseAreas()) {
|
||||
builder.appendEscaped(courseArea.name);
|
||||
builder.appendEscaped(courseArea.getName());
|
||||
if (i < courseAreasCount) {
|
||||
builder.appendHtmlConstant("<br>");
|
||||
}
|
||||
@@ -145,7 +145,7 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
@Override
|
||||
public void update(int index, EventDTO event, String value) {
|
||||
if (EventConfigImagesBarCell.ACTION_REMOVE.equals(value)) {
|
||||
if (Window.confirm(stringMessages.doYouReallyWantToRemoveRegatta(event.name))) {
|
||||
if (Window.confirm(stringMessages.doYouReallyWantToRemoveRegatta(event.getName()))) {
|
||||
removeEvent(event);
|
||||
}
|
||||
} else if (EventConfigImagesBarCell.ACTION_EDIT.equals(value)) {
|
||||
@@ -181,7 +181,7 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
sailingService.removeEvent(event.id, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
errorReporter.reportError("Error trying to remove event " + event.name + ": " + caught.getMessage());
|
||||
errorReporter.reportError("Error trying to remove event " + event.getName() + ": " + caught.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -231,25 +231,25 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
// }
|
||||
List<CourseAreaDTO> courseAreasToAdd = getCourseAreasToAdd(oldEvent, updatedEvent);
|
||||
|
||||
sailingService.updateEvent(oldEvent.name, oldEvent.id, updatedEvent.venue, updatedEvent.publicationUrl,
|
||||
sailingService.updateEvent(oldEvent.getName(), oldEvent.id, updatedEvent.venue, updatedEvent.publicationUrl,
|
||||
updatedEvent.isPublic, regattaNames, new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to update sailing event" + oldEvent.name + ": " + t.getMessage());
|
||||
errorReporter.reportError("Error trying to update sailing event" + oldEvent.getName() + ": " + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
fillEvents();
|
||||
if(!oldEvent.name.equals(updatedEvent.name)) {
|
||||
sailingService.renameEvent(oldEvent.id, updatedEvent.name, new AsyncCallback<Void>() {
|
||||
if(!oldEvent.getName().equals(updatedEvent.getName())) {
|
||||
sailingService.renameEvent(oldEvent.id, updatedEvent.getName(), new AsyncCallback<Void>() {
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
fillEvents();
|
||||
}
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to rename sailing event " + oldEvent.name + ": " + t.getMessage());
|
||||
errorReporter.reportError("Error trying to rename sailing event " + oldEvent.getName() + ": " + t.getMessage());
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -258,11 +258,11 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
|
||||
if (courseAreasToAdd.size() > 0) {
|
||||
for (CourseAreaDTO courseArea : courseAreasToAdd) {
|
||||
sailingService.createCourseArea(oldEvent.id, courseArea.name, new AsyncCallback<CourseAreaDTO>() {
|
||||
sailingService.createCourseArea(oldEvent.id, courseArea.getName(), new AsyncCallback<CourseAreaDTO>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to add course area to sailing event " + oldEvent.name + ": " + t.getMessage());
|
||||
errorReporter.reportError("Error trying to add course area to sailing event " + oldEvent.getName() + ": " + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -281,12 +281,12 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
|
||||
List<String> newCourseAreaNames = new ArrayList<String>();
|
||||
for(CourseAreaDTO courseArea : updatedEvent.venue.getCourseAreas()) {
|
||||
newCourseAreaNames.add(courseArea.name);
|
||||
newCourseAreaNames.add(courseArea.getName());
|
||||
}
|
||||
|
||||
List<String> oldCourseAreaNames = new ArrayList<String>();
|
||||
for(CourseAreaDTO courseArea : oldEvent.venue.getCourseAreas()) {
|
||||
oldCourseAreaNames.add(courseArea.name);
|
||||
oldCourseAreaNames.add(courseArea.getName());
|
||||
}
|
||||
|
||||
for (String newCourseAreaName : newCourseAreaNames) {
|
||||
@@ -295,7 +295,7 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
}
|
||||
|
||||
for(CourseAreaDTO courseArea : updatedEvent.venue.getCourseAreas()) {
|
||||
if (courseAreaNamesToAdd.contains(courseArea.name)) {
|
||||
if (courseAreaNamesToAdd.contains(courseArea.getName())) {
|
||||
courseAreasToAdd.add(courseArea);
|
||||
}
|
||||
}
|
||||
@@ -306,12 +306,12 @@ public class SailingEventManagementPanel extends SimplePanel {
|
||||
private void createNewEvent(final EventDTO newEvent) {
|
||||
List<String> courseAreaNames = new ArrayList<String>();
|
||||
for (CourseAreaDTO courseAreaDTO : newEvent.venue.getCourseAreas()) {
|
||||
courseAreaNames.add(courseAreaDTO.name);
|
||||
courseAreaNames.add(courseAreaDTO.getName());
|
||||
}
|
||||
sailingService.createEvent(newEvent.name, newEvent.venue.name, newEvent.publicationUrl, newEvent.isPublic, courseAreaNames, new AsyncCallback<EventDTO>() {
|
||||
sailingService.createEvent(newEvent.getName(), newEvent.venue.getName(), newEvent.publicationUrl, newEvent.isPublic, courseAreaNames, new AsyncCallback<EventDTO>() {
|
||||
@Override
|
||||
public void onFailure(Throwable t) {
|
||||
errorReporter.reportError("Error trying to create new event" + newEvent.name + ": " + t.getMessage());
|
||||
errorReporter.reportError("Error trying to create new event" + newEvent.getName() + ": " + t.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+13
-13
@@ -56,16 +56,16 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
List<RaceColumnDTO> raceColumnsToValidate = valueToValidate.getRaces();
|
||||
String errorMessage = null;
|
||||
for (SeriesDTO seriesDTO: regatta.series) {
|
||||
if (!seriesDTO.name.equals(seriesToValidate.name)) {
|
||||
if (!seriesDTO.getName().equals(seriesToValidate.getName())) {
|
||||
for (RaceColumnDTO raceColumn : seriesDTO.getRaceColumns()) {
|
||||
raceColumnNamesOfOtherSeries.add(raceColumn.name);
|
||||
raceColumnNamesOfOtherSeries.add(raceColumn.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
boolean raceColumnNameNotEmpty = true;
|
||||
RaceColumnDTO wrongRaceColumn = null;
|
||||
for (RaceColumnDTO raceColumn : raceColumnsToValidate) {
|
||||
raceColumnNameNotEmpty = raceColumn.name != null && raceColumn.name.length() > 0;
|
||||
raceColumnNameNotEmpty = raceColumn.getName() != null && raceColumn.getName().length() > 0;
|
||||
if (!raceColumnNameNotEmpty) {
|
||||
wrongRaceColumn = raceColumn;
|
||||
break;
|
||||
@@ -75,24 +75,24 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
boolean raceColumnUniqueInRegatta = true;
|
||||
HashSet<String> setToFindDuplicates = new HashSet<String>();
|
||||
for (RaceColumnDTO raceColumn : raceColumnsToValidate) {
|
||||
if (!setToFindDuplicates.add(raceColumn.name)) {
|
||||
if (!setToFindDuplicates.add(raceColumn.getName())) {
|
||||
raceColumnUniqueInSeries = false;
|
||||
wrongRaceColumn = raceColumn;
|
||||
break;
|
||||
} else if(raceColumnNamesOfOtherSeries.contains(raceColumn.name)) {
|
||||
} else if(raceColumnNamesOfOtherSeries.contains(raceColumn.getName())) {
|
||||
raceColumnUniqueInRegatta = false;
|
||||
wrongRaceColumn = raceColumn;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!raceColumnNameNotEmpty) {
|
||||
errorMessage = stringMessages.race() + " " + wrongRaceColumn.name + ": "
|
||||
errorMessage = stringMessages.race() + " " + wrongRaceColumn.getName() + ": "
|
||||
+ stringMessages.pleaseEnterAName();
|
||||
} else if (!raceColumnUniqueInSeries) {
|
||||
errorMessage = stringMessages.race() + " " + wrongRaceColumn.name + ": "
|
||||
errorMessage = stringMessages.race() + " " + wrongRaceColumn.getName() + ": "
|
||||
+ stringMessages.raceWithThisNameAlreadyExists();
|
||||
} else if (!raceColumnUniqueInRegatta) {
|
||||
errorMessage = stringMessages.race() + " " + wrongRaceColumn.name + ": "
|
||||
errorMessage = stringMessages.race() + " " + wrongRaceColumn.getName() + ": "
|
||||
+ stringMessages.raceWithThisNameAlreadyExistsInRegatta();
|
||||
} else {
|
||||
errorMessage = DiscardThresholdBoxes.getErrorMessage(valueToValidate.getResultDiscardingThresholds(), stringMessages);
|
||||
@@ -102,7 +102,7 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
}
|
||||
|
||||
public SeriesEditDialog(RegattaDTO regatta, SeriesDTO selectedSeries, StringMessages stringMessages,DialogCallback<SeriesDescriptor> callback) {
|
||||
super(stringMessages.actionEditRaces(), null, stringMessages.ok(), stringMessages.cancel(),
|
||||
super(stringMessages.actionEditSeries(), null, stringMessages.ok(), stringMessages.cancel(),
|
||||
new RaceDialogValidator(regatta, stringMessages), callback);
|
||||
this.selectedSeries = selectedSeries;
|
||||
this.stringMessages = stringMessages;
|
||||
@@ -155,7 +155,7 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
RaceColumnDTO raceColumnDTO = findRaceColumnInSeriesByName(selectedSeries, raceColumnName);
|
||||
if (raceColumnDTO == null) {
|
||||
raceColumnDTO = new RaceColumnDTO(/* isValidInTotalScore not relevant here; not in scope of a leaderboard */ null);
|
||||
raceColumnDTO.name = raceColumnName;
|
||||
raceColumnDTO.setName(raceColumnName);
|
||||
}
|
||||
races.add(raceColumnDTO);
|
||||
}
|
||||
@@ -168,7 +168,7 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
RaceColumnDTO result = null;
|
||||
if(series != null) {
|
||||
for(RaceColumnDTO raceColumn: series.getRaceColumns()) {
|
||||
if(raceColumn.name.equals(raceColumnName)) {
|
||||
if(raceColumn.getName().equals(raceColumnName)) {
|
||||
result = raceColumn;
|
||||
break;
|
||||
}
|
||||
@@ -186,7 +186,7 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
}
|
||||
HorizontalPanel seriesPanel = new HorizontalPanel();
|
||||
seriesPanel.setSpacing(3);
|
||||
String seriesName = getSelectedSeries().name;
|
||||
String seriesName = getSelectedSeries().getName();
|
||||
seriesPanel.add(new Label(stringMessages.series() + ": " + seriesName));
|
||||
additionalWidgetPanel.add(seriesPanel);
|
||||
isMedalCheckbox = createCheckbox(stringMessages.medalSeries());
|
||||
@@ -264,7 +264,7 @@ public class SeriesEditDialog extends DataEntryDialog<SeriesDescriptor> {
|
||||
raceNameDeleteButtons.clear();
|
||||
if(selectedSeries != null && !selectedSeries.getRaceColumns().isEmpty()) {
|
||||
for(RaceColumnDTO raceColumn: selectedSeries.getRaceColumns()) {
|
||||
createRaceNameWidget(raceColumn.name, false);
|
||||
createRaceNameWidget(raceColumn.getName(), false);
|
||||
createRaceNameDeleteButtonWidget();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -55,10 +55,10 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
@Override
|
||||
public String getErrorMessage(SeriesDTO seriesToValidate) {
|
||||
String errorMessage = null;
|
||||
boolean nameNotEmpty = seriesToValidate.name != null && seriesToValidate.name.length() > 0;
|
||||
boolean nameNotEmpty = seriesToValidate.getName() != null && seriesToValidate.getName().length() > 0;
|
||||
boolean unique = true;
|
||||
for (SeriesDTO series : existingSeries) {
|
||||
if (series.name.equals(seriesToValidate.name)) {
|
||||
if (series.getName().equals(seriesToValidate.getName())) {
|
||||
unique = false;
|
||||
break;
|
||||
}
|
||||
@@ -73,7 +73,7 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
int index = 0;
|
||||
boolean fleetNameNotEmpty = true;
|
||||
for (FleetDTO fleet : fleetsToValidate) {
|
||||
fleetNameNotEmpty = fleet.name != null && fleet.name.length() > 0;
|
||||
fleetNameNotEmpty = fleet.getName() != null && fleet.getName().length() > 0;
|
||||
if (!fleetNameNotEmpty) {
|
||||
break;
|
||||
}
|
||||
@@ -83,7 +83,7 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
boolean fleetUnique = true;
|
||||
HashSet<String> setToFindDuplicates = new HashSet<String>();
|
||||
for (FleetDTO fleet: fleetsToValidate) {
|
||||
if(!setToFindDuplicates.add(fleet.name)) {
|
||||
if(!setToFindDuplicates.add(fleet.getName())) {
|
||||
fleetUnique = false;
|
||||
break;
|
||||
}
|
||||
@@ -178,14 +178,14 @@ public class SeriesWithFleetsCreateDialog extends DataEntryDialog<SeriesDTO> {
|
||||
|
||||
@Override
|
||||
protected SeriesDTO getResult() {
|
||||
series.name = nameEntryField.getText();
|
||||
series.setName(nameEntryField.getText());
|
||||
series.setMedal(isMedalSeriesCheckbox.getValue());
|
||||
series.setStartsWithZeroScore(startsWithZeroScoreCheckbox.getValue());
|
||||
List<FleetDTO> fleets = new ArrayList<FleetDTO>();
|
||||
int fleetsCount = fleetNameEntryFields.size();
|
||||
for(int i = 0; i < fleetsCount; i++) {
|
||||
FleetDTO fleetDTO = new FleetDTO();
|
||||
fleetDTO.name = fleetNameEntryFields.get(i).getValue();
|
||||
fleetDTO.setName(fleetNameEntryFields.get(i).getValue());
|
||||
fleetDTO.setColor(getSelectedColor(fleetColorEntryFields.get(i)));
|
||||
int orderNo = -1;
|
||||
if(fleetOrderNoEntryFields.get(i).getValue() != null) {
|
||||
|
||||
+1
-1
@@ -378,7 +378,7 @@ public class SwissTimingEventManagementPanel extends AbstractEventManagementPane
|
||||
RegattaDTO selectedRegatta = getSelectedRegatta();
|
||||
RegattaIdentifier regattaIdentifier = null;
|
||||
if (selectedRegatta != null) {
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.name);
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.getName());
|
||||
}
|
||||
sailingService.trackWithSwissTiming(
|
||||
/* regattaToAddTo */ regattaIdentifier,
|
||||
|
||||
+4
-4
@@ -341,12 +341,12 @@ public class SwissTimingReplayConnectorPanel extends AbstractEventManagementPane
|
||||
// in case no regatta has been selected we check if there would be a matching regatta
|
||||
for (RegattaDTO regatta : getAvailableRegattas()) {
|
||||
if ((boatClassName == null && regatta.boatClass == null) ||
|
||||
(regatta.boatClass != null && boatClassName.equalsIgnoreCase(regatta.boatClass.name))) {
|
||||
(regatta.boatClass != null && boatClassName.equalsIgnoreCase(regatta.boatClass.getName()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!boatClassName.equalsIgnoreCase(selectedRegatta.boatClass.name)) {
|
||||
if (!boatClassName.equalsIgnoreCase(selectedRegatta.boatClass.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -358,7 +358,7 @@ public class SwissTimingReplayConnectorPanel extends AbstractEventManagementPane
|
||||
RegattaDTO selectedRegatta = getSelectedRegatta();
|
||||
RegattaIdentifier regattaIdentifier = null;
|
||||
if (selectedRegatta != null) {
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.name);
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.getName());
|
||||
}
|
||||
|
||||
// Check if the assigned regatta makes sense
|
||||
@@ -375,7 +375,7 @@ public class SwissTimingReplayConnectorPanel extends AbstractEventManagementPane
|
||||
String warningText = "WARNING\n";
|
||||
if (selectedRegatta != null) {
|
||||
warningText += stringMessages.boatClassDoesNotMatchSelectedRegatta(
|
||||
selectedRegatta.boatClass==null?"":selectedRegatta.boatClass.name, selectedRegatta.name);
|
||||
selectedRegatta.boatClass==null?"":selectedRegatta.boatClass.getName(), selectedRegatta.getName());
|
||||
} else {
|
||||
warningText += stringMessages.regattaExistForSelectedBoatClass();
|
||||
}
|
||||
|
||||
+5
-5
@@ -658,12 +658,12 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
// in case no regatta has been selected we check if there would be a matching regatta
|
||||
for (RegattaDTO regatta : getAvailableRegattas()) {
|
||||
if ((tracTracBoatClassName == null && regatta.boatClass == null) ||
|
||||
(regatta.boatClass != null && tracTracBoatClassName.equalsIgnoreCase(regatta.boatClass.name))) {
|
||||
(regatta.boatClass != null && tracTracBoatClassName.equalsIgnoreCase(regatta.boatClass.getName()))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!tracTracBoatClassName.equalsIgnoreCase(selectedRegatta.boatClass.name)) {
|
||||
if (!tracTracBoatClassName.equalsIgnoreCase(selectedRegatta.boatClass.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -680,7 +680,7 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
RegattaDTO selectedRegatta = getSelectedRegatta();
|
||||
RegattaIdentifier regattaIdentifier = null;
|
||||
if (selectedRegatta != null) {
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.name);
|
||||
regattaIdentifier = new RegattaName(selectedRegatta.getName());
|
||||
}
|
||||
// Check if the assigned regatta makes sense
|
||||
List<TracTracRaceRecordDTO> allRaces = this.raceList.getList();
|
||||
@@ -698,8 +698,8 @@ public class TracTracEventManagementPanel extends AbstractEventManagementPanel {
|
||||
builder.append("WARNING\n");
|
||||
if (selectedRegatta != null) {
|
||||
builder.append(this.stringMessages.boatClassDoesNotMatchSelectedRegatta(
|
||||
selectedRegatta.boatClass==null?"":selectedRegatta.boatClass.name,
|
||||
selectedRegatta.name));
|
||||
selectedRegatta.boatClass==null?"":selectedRegatta.boatClass.getName(),
|
||||
selectedRegatta.getName()));
|
||||
} else {
|
||||
builder.append(this.stringMessages.regattaExistForSelectedBoatClass());
|
||||
}
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ package com.sap.sailing.gwt.ui.client;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack;
|
||||
import com.sap.sailing.domain.common.media.MediaTrack;
|
||||
|
||||
public interface MediaPlayer {
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import java.util.Collection;
|
||||
import com.google.gwt.user.client.rpc.RemoteService;
|
||||
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack;
|
||||
import com.sap.sailing.domain.common.media.MediaTrack;
|
||||
|
||||
@RemoteServiceRelativePath("media")
|
||||
public interface MediaService extends RemoteService {
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ import java.util.Collection;
|
||||
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sap.sailing.domain.common.RegattaAndRaceIdentifier;
|
||||
import com.sap.sailing.gwt.ui.client.shared.media.MediaTrack;
|
||||
import com.sap.sailing.domain.common.media.MediaTrack;
|
||||
|
||||
public interface MediaServiceAsync {
|
||||
|
||||
|
||||
+1
-1
@@ -227,7 +227,7 @@ public class RaceTimePanel extends TimePanel<RaceTimePanelSettings> implements R
|
||||
if (markPassingTimesDTO.firstPassingDate != null) {
|
||||
long markerTime = markPassingTimesDTO.firstPassingDate.getTime();
|
||||
if(!timeSlider.isZoomed() || (timeSlider.isZoomed() && markerTime > timeSlider.getMinValue() && markerTime < timeSlider.getMaxValue())) {
|
||||
timeSlider.addMarker(markPassingTimesDTO.name, new Double(markerTime));
|
||||
timeSlider.addMarker(markPassingTimesDTO.getName(), new Double(markerTime));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -23,7 +23,7 @@ import com.sap.sailing.domain.common.RegattaIdentifier;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.IncrementalOrFullLeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnInSeriesDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceDTO;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
@@ -116,8 +116,8 @@ public interface SailingService extends RemoteService {
|
||||
|
||||
public List<String> getLeaderboardNames() throws Exception;
|
||||
|
||||
LeaderboardDTO getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails) throws Exception;
|
||||
IncrementalOrFullLeaderboardDTO getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails, String previousLeaderboardId) throws Exception;
|
||||
|
||||
List<StrippedLeaderboardDTO> getLeaderboards();
|
||||
|
||||
|
||||
+2
-20
@@ -23,8 +23,7 @@ import com.sap.sailing.domain.common.RegattaNameAndRaceName;
|
||||
import com.sap.sailing.domain.common.ScoringSchemeType;
|
||||
import com.sap.sailing.domain.common.WindSource;
|
||||
import com.sap.sailing.domain.common.dto.CompetitorDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.LeaderboardEntryDTO;
|
||||
import com.sap.sailing.domain.common.dto.IncrementalOrFullLeaderboardDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceColumnInSeriesDTO;
|
||||
import com.sap.sailing.domain.common.dto.RaceDTO;
|
||||
import com.sap.sailing.domain.common.impl.Util.Pair;
|
||||
@@ -161,26 +160,9 @@ public interface SailingServiceAsync {
|
||||
|
||||
void getCoursePositions(RegattaAndRaceIdentifier raceIdentifier, Date date, AsyncCallback<CoursePositionsDTO> asyncCallback);
|
||||
|
||||
/**
|
||||
* Returns a {@link LeaderboardDTO} will information about all races, their points and competitor display names
|
||||
* filled in. The column details are filled for the races whose named are provided in
|
||||
* <code>namesOfRacesForWhichToLoadLegDetails</code>.
|
||||
*
|
||||
* @param date
|
||||
* the time point for the leaderboard data to retrieve, or <code>null</code> for "live mode" which means
|
||||
* that the server will produce whatever it has ready for the currently active live delay set on the
|
||||
* server; in live mode, data served may be taken from caches that lag up to a few seconds.
|
||||
* @param namesOfRaceColumnsForWhichToLoadLegDetails
|
||||
* if <code>null</code>, no {@link LeaderboardEntryDTO#legDetails leg details} will be present in the
|
||||
* result ({@link LeaderboardEntryDTO#legDetails} will be <code>null</code> for all
|
||||
* {@link LeaderboardEntryDTO} objects contained). Otherwise, the {@link LeaderboardEntryDTO#legDetails}
|
||||
* list will contain one entry per leg of the race {@link com.sap.sailing.domain.base.Course} for those race columns whose
|
||||
* {@link com.sap.sailing.domain.base.RaceColumn#getType() name} is contained in <code>namesOfRacesForWhichToLoadLegDetails</code>.
|
||||
* For all other columns, {@link LeaderboardEntryDTO#legDetails} is <code>null</code>.
|
||||
*/
|
||||
void getLeaderboardByName(String leaderboardName, Date date,
|
||||
Collection<String> namesOfRaceColumnsForWhichToLoadLegDetails,
|
||||
AsyncCallback<LeaderboardDTO> callback);
|
||||
String previousLeaderboardId, AsyncCallback<IncrementalOrFullLeaderboardDTO> callback);
|
||||
|
||||
void getLeaderboardNames(AsyncCallback<List<String>> callback);
|
||||
|
||||
|
||||
Loaded 100 of 185 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user