From e91c19dff66859a67b3ce511f5164f63c4d53414 Mon Sep 17 00:00:00 2001 From: Steffen Schaefer Date: Fri, 12 Apr 2019 11:24:42 +0200 Subject: [PATCH 1/3] Bug 4980: In LeaderboardPanel we now prefer to show the sail ID instead of the competitor short name for leaderboards where boats can't change. For leaderboard with changing boats, we still prefer the competitor short name. The same applies to EditableLeaderboardPanel. --- .../domain/common/dto/CompetitorDTO.java | 9 +++++++ .../domain/common/dto/CompetitorDTOImpl.java | 11 +++++--- .../common/dto/CompetitorWithBoatDTOImpl.java | 8 +++--- .../common/dto/PreviousCompetitorDTOImpl.java | 6 +++++ .../gwt/ui/leaderboard/LeaderboardPanel.java | 25 +++++++++++++------ .../EditableLeaderboardPanel.java | 16 ++++++++++-- 6 files changed, 60 insertions(+), 15 deletions(-) diff --git a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTO.java b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTO.java index a62de9e107f..8259b035046 100644 --- a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTO.java +++ b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTO.java @@ -38,6 +38,15 @@ public interface CompetitorDTO extends Serializable, MappableToDevice { * of the competitor's {@link #getName() name} unless it's empty in which case an empty string is returned. */ String getShortInfo(); + + /** + * Returns a derived short information about a competitor depending on the information available. + * Depending on the given preferSailId we prefer either {@link #getShortName() short name} or the sail ID from {@link CompetitorWithBoatDTO#getBoat() boat} + * if available. If both values aren't available, the boat name is used if a boat is available. If all these + * attributes have no value, a three-letter acronym is constructed from the name by using the first two and the last letter + * of the competitor's {@link #getName() name} unless it's empty in which case an empty string is returned. + */ + String getShortInfo(boolean preferSailId); Color getColor(); diff --git a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTOImpl.java b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTOImpl.java index 7c641c44377..0a5a1dd2bd1 100755 --- a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTOImpl.java +++ b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorDTOImpl.java @@ -155,6 +155,11 @@ public class CompetitorDTOImpl extends NamedDTO implements CompetitorDTO, Serial @Override public String getShortInfo() { + return getShortInfo(false); + } + + @Override + public String getShortInfo(boolean preferSailId) { final String result; if (getShortName() != null && !getShortName().trim().isEmpty()) { result = getShortName(); @@ -164,9 +169,9 @@ public class CompetitorDTOImpl extends NamedDTO implements CompetitorDTO, Serial result = null; } else { result = (trimmedName.length()>0?""+trimmedName.charAt(0):"") - + (trimmedName.length()>1?trimmedName.charAt(1):"") - + (trimmedName.length()>0?trimmedName.charAt(trimmedName.length()-1):""); - + + (trimmedName.length()>1?trimmedName.charAt(1):"") + + (trimmedName.length()>0?trimmedName.charAt(trimmedName.length()-1):""); + } } return result; diff --git a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorWithBoatDTOImpl.java b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorWithBoatDTOImpl.java index d51e2cc723d..8cc19cf4ad3 100644 --- a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorWithBoatDTOImpl.java +++ b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/CompetitorWithBoatDTOImpl.java @@ -59,11 +59,13 @@ public class CompetitorWithBoatDTOImpl extends CompetitorDTOImpl implements Comp public CompetitorWithBoatDTO getCompetitorFromPrevious(LeaderboardDTO previousVersion) { return this; } - + @Override - public String getShortInfo() { + public String getShortInfo(boolean preferSailId) { final String result; - if (getShortName() != null && !getShortName().trim().isEmpty()) { + if (preferSailId && getBoat() != null && getBoat().getSailId() != null) { + result = getBoat().getSailId(); + } else if (getShortName() != null && !getShortName().trim().isEmpty()) { result = getShortName(); } else if (getBoat() != null) { result = getBoat().getSailId() != null ? getBoat().getSailId() : getBoat().getName(); diff --git a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/PreviousCompetitorDTOImpl.java b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/PreviousCompetitorDTOImpl.java index 367ab2102cf..b0c4771c0aa 100755 --- a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/PreviousCompetitorDTOImpl.java +++ b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/dto/PreviousCompetitorDTOImpl.java @@ -52,6 +52,12 @@ public class PreviousCompetitorDTOImpl implements CompetitorDTO { throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+ " need to be replaced by an object of "+CompetitorWithBoatDTOImpl.class.getName()+" after deserialization"); } + + @Override + public String getShortInfo(boolean preferSailId) { + throw new RuntimeException("Internal error. Objects of type "+PreviousCompetitorDTOImpl.class.getName()+ + " need to be replaced by an object of "+CompetitorWithBoatDTOImpl.class.getName()+" after deserialization"); + } @Override public String getTwoLetterIsoCountryCode() { diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboard/LeaderboardPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboard/LeaderboardPanel.java index d91b72d7191..43664b8b530 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboard/LeaderboardPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboard/LeaderboardPanel.java @@ -875,17 +875,28 @@ public abstract class LeaderboardPanel extends A // an overflow to the next column (see https://bugzilla.sapsailing.com/bugzilla/show_bug.cgi?id=3537) setCellStyleNames(style.getTableresources().cellTableStyle().cellTableSailIdColumn()); } + + /** + * Depending on the {@link LeaderboardDTO LeaderboardDTO's} + * {@link AbstractLeaderboardDTO#canBoatsOfCompetitorsChangePerRace canBoatsOfCompetitorsChangePerRace} flag + * there is a different precedence of showing either the sail ID (no changing boats) or the competitor short + * name (changing boats). This method handles the resolution of the text to show for a competitor in this column. + */ + private String getRealTextToShow(CompetitorDTO competitor) { + boolean preferSailId = !getLeaderboard().canBoatsOfCompetitorsChangePerRace; + return competitor.getShortInfo(preferSailId); + } @Override public InvertibleComparator getComparator() { return new InvertibleComparatorAdapter() { @Override public int compare(T o1, T o2) { - return competitorFetcher.getCompetitor(o1).getShortInfo() == null - ? competitorFetcher.getCompetitor(o2).getShortInfo() == null ? 0 : -1 - : competitorFetcher.getCompetitor(o2).getShortInfo() == null ? 1 - : Collator.getInstance().compare(competitorFetcher.getCompetitor(o1).getShortInfo(), - competitorFetcher.getCompetitor(o2).getShortInfo()); + final String competitor1ShortInfo = getRealTextToShow(competitorFetcher.getCompetitor(o1)); + final String competitor2ShortInfo = getRealTextToShow(competitorFetcher.getCompetitor(o2)); + return competitor1ShortInfo == null ? competitor2ShortInfo == null ? 0 : -1 + : competitor2ShortInfo == null ? 1 + : Collator.getInstance().compare(competitor1ShortInfo, competitor2ShortInfo); } }; } @@ -900,12 +911,12 @@ public abstract class LeaderboardPanel extends A public void render(Context context, T object, SafeHtmlBuilder sb) { final CompetitorDTO competitor = competitorFetcher.getCompetitor(object); LeaderboardPanel.this.renderCompetitorText(competitor, isShowCompetitorShortName(), - !isShowCompetitorFullName(), sb, builder -> builder.appendEscaped(competitor.getShortInfo())); + !isShowCompetitorFullName(), sb, builder -> builder.appendEscaped(getRealTextToShow(competitor))); } @Override public String getValue(T object) { - return competitorFetcher.getCompetitor(object).getShortInfo(); + return getRealTextToShow(competitorFetcher.getCompetitor(object)); } } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboardedit/EditableLeaderboardPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboardedit/EditableLeaderboardPanel.java index 2e450a867cd..5788cac4d9e 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboardedit/EditableLeaderboardPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/leaderboardedit/EditableLeaderboardPanel.java @@ -45,6 +45,7 @@ import com.sap.sailing.domain.common.DetailType; import com.sap.sailing.domain.common.InvertibleComparator; import com.sap.sailing.domain.common.MaxPointsReason; import com.sap.sailing.domain.common.SortingOrder; +import com.sap.sailing.domain.common.dto.AbstractLeaderboardDTO; import com.sap.sailing.domain.common.dto.CompetitorDTO; import com.sap.sailing.domain.common.dto.LeaderboardDTO; import com.sap.sailing.domain.common.dto.LeaderboardEntryDTO; @@ -133,12 +134,23 @@ public class EditableLeaderboardPanel extends MultiRaceLeaderboardPanel { super(new TextCell(), SortingOrder.ASCENDING, EditableLeaderboardPanel.this); } + /** + * Depending on the {@link LeaderboardDTO LeaderboardDTO's} + * {@link AbstractLeaderboardDTO#canBoatsOfCompetitorsChangePerRace canBoatsOfCompetitorsChangePerRace} flag + * there is a different precedence of showing either the sail ID (no changing boats) or the competitor short + * name (changing boats). This method handles the resolution of the text to show for a competitor in this column. + */ + private String getRealTextToShow(CompetitorDTO competitor) { + boolean preferSailId = !getLeaderboard().canBoatsOfCompetitorsChangePerRace; + return competitor.getShortInfo(preferSailId); + } + @Override public InvertibleComparator getComparator() { return new InvertibleComparatorAdapter() { @Override public int compare(CompetitorDTO o1, CompetitorDTO o2) { - return Collator.getInstance().compare(o1.getShortInfo(), o2.getShortInfo()); + return Collator.getInstance().compare(getRealTextToShow(o1), getRealTextToShow(o2)); } }; } @@ -161,7 +173,7 @@ public class EditableLeaderboardPanel extends MultiRaceLeaderboardPanel { sb.append(FlagImageRenderer.image(flagImageResource.getSafeUri().asString())); sb.appendHtmlConstant(" "); } - sb.appendEscaped(object.getShortInfo()); + sb.appendEscaped(getRealTextToShow(object)); } @Override From b435c9e4e46a6348fb4defa844c3498fe51ce67a Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Fri, 12 Apr 2019 11:43:07 +0200 Subject: [PATCH 2/3] added a "raw" parameter to the /positions end point Change-Id: Ic9e250a548cc82fe2845d08e5d59d673bb7d2337 --- .../server/gateway/jaxrs/api/RegattasResource.java | 11 +++++++---- .../api/v1/raceCompetitorPositionsGetDoc.html | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/RegattasResource.java b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/RegattasResource.java index 5fb550306be..3fb69eb011f 100644 --- a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/RegattasResource.java +++ b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/api/RegattasResource.java @@ -466,7 +466,8 @@ public class RegattasResource extends AbstractSailingServerResource { @QueryParam("fromtimeasmillis") Long fromtimeasmillis, @QueryParam("totime") String totime, @QueryParam("totimeasmillis") Long totimeasmillis, @QueryParam("withtack") Boolean withTack, @QueryParam("competitorId") Set competitorIds, - @DefaultValue("false") @QueryParam("lastknown") boolean addLastKnown) { + @DefaultValue("false") @QueryParam("lastknown") boolean addLastKnown, + @DefaultValue("false") @QueryParam("raw") boolean raw) { Response response; Regatta regatta = findRegattaByName(regattaName); if (regatta == null) { @@ -517,9 +518,9 @@ public class RegattasResource extends AbstractSailingServerResource { try { Iterator fixIter; if (from == null) { - fixIter = track.getFixes().iterator(); + fixIter = raw?track.getRawFixes().iterator():track.getFixes().iterator(); } else { - fixIter = track.getFixesIterator(from, /* inclusive */true); + fixIter = raw?track.getRawFixesIterator(from, /* inclusive */true):track.getFixesIterator(from, /* inclusive */true); } GPSFixMoving fix = null; boolean lastAdded = false; @@ -543,7 +544,9 @@ public class RegattasResource extends AbstractSailingServerResource { if (addLastKnown && !lastAdded) { // find a fix earlier than the interval requested: - Iterator earlierFixIter = track.getFixesDescendingIterator(from, /* inclusive */false); + Iterator earlierFixIter = raw ? + track.getRawFixesDescendingIterator(from, /* inclusive */false) : + track.getFixesDescendingIterator(from, /* inclusive */false); final GPSFixMoving earlierFix; if (earlierFixIter.hasNext()) { earlierFix = earlierFixIter.next(); diff --git a/java/com.sap.sailing.server.gateway/webservices/api/v1/raceCompetitorPositionsGetDoc.html b/java/com.sap.sailing.server.gateway/webservices/api/v1/raceCompetitorPositionsGetDoc.html index ba0682daf21..d7de1d95fba 100644 --- a/java/com.sap.sailing.server.gateway/webservices/api/v1/raceCompetitorPositionsGetDoc.html +++ b/java/com.sap.sailing.server.gateway/webservices/api/v1/raceCompetitorPositionsGetDoc.html @@ -37,6 +37,7 @@ All slashes contained within the {regattaname} and {racename} parameters must be
totimeasmillis
withtack ("true" or "false"; default is "false"; "true" adds the tack to each fix which is expensive to calculate)
competitorId (one or more competitor IDs; for multiple competitors, provide the parameter multiple times; by default, positions of all competitors will be provided)
+
raw ("true" or "false"; default is "false"; if "true" the result will also contain fixes that are considered outliers)
From b1c6625158a7f7272de35e54d6f3d95cf6c1fd2d Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Fri, 12 Apr 2019 21:47:29 +0200 Subject: [PATCH 3/3] removed obsolete "Proxy" launch configs Change-Id: I115bcbc45b483c9eca5c69ee112f7827b31ac421 --- .../SailingServer (Proxy).launch | 41 ------------------- ...ailingServer (Proxy, Jetty on 8889).launch | 32 --------------- ...ty on 8889, Polar Import from 8888).launch | 32 --------------- ...oxy, Jetty on 8889, auto-replicate).launch | 32 --------------- ...ailingServer (Proxy, Jetty on 8890).launch | 32 --------------- ...uto-replicate from replica at 8889).launch | 32 --------------- ...uto-replicate only SecurityService).launch | 32 --------------- ...Server (Proxy, Remote Debug SAP VM).launch | 31 -------------- ...Proxy, SwissTiming Live Simulation).launch | 30 -------------- .../SailingServer (Proxy, winddbTest).launch | 33 --------------- 10 files changed, 327 deletions(-) delete mode 100644 java/com.sap.sailing.server/SailingServer (Proxy).launch delete mode 100644 java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch delete mode 100755 java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, Polar Import from 8888).launch delete mode 100755 java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, auto-replicate).launch delete mode 100755 java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890).launch delete mode 100755 java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate from replica at 8889).launch delete mode 100755 java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate only SecurityService).launch delete mode 100644 java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch delete mode 100644 java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch delete mode 100644 java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch diff --git a/java/com.sap.sailing.server/SailingServer (Proxy).launch b/java/com.sap.sailing.server/SailingServer (Proxy).launch deleted file mode 100644 index 5f8442ea4d8..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy).launch +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch deleted file mode 100644 index 9f4dab3acf5..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889).launch +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, Polar Import from 8888).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, Polar Import from 8888).launch deleted file mode 100755 index 7125ff0c987..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, Polar Import from 8888).launch +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, auto-replicate).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, auto-replicate).launch deleted file mode 100755 index 8759056d7ff..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8889, auto-replicate).launch +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890).launch deleted file mode 100755 index 19b2248822c..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890).launch +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate from replica at 8889).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate from replica at 8889).launch deleted file mode 100755 index 66a83b7438f..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate from replica at 8889).launch +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate only SecurityService).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate only SecurityService).launch deleted file mode 100755 index 5919bc15af2..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Jetty on 8890, auto-replicate only SecurityService).launch +++ /dev/null @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch b/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch deleted file mode 100644 index 6f0fdf5626e..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, Remote Debug SAP VM).launch +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch b/java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch deleted file mode 100644 index 31231d8aa93..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, SwissTiming Live Simulation).launch +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch b/java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch deleted file mode 100644 index 59000700253..00000000000 --- a/java/com.sap.sailing.server/SailingServer (Proxy, winddbTest).launch +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -