From 120c40cc1be96f108bb72cb859ba9d7a760ede67 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 18 Mar 2014 12:58:12 +0100 Subject: [PATCH 1/6] fixing bug 1856 by avoiding NPE in case of unknown speed/bearing around maneuver --- .../domain/tracking/impl/TrackedRaceImpl.java | 74 ++++++++++--------- 1 file changed, 39 insertions(+), 35 deletions(-) diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java index fea5714202d..7d5d9d6d6c0 100755 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/tracking/impl/TrackedRaceImpl.java @@ -2099,43 +2099,47 @@ public abstract class TrackedRaceImpl extends TrackedRaceWithWindEssentials impl sideToWhichWaypointWasPassed)); } final Wind wind = getWind(maneuverPosition, maneuverTimePoint); - final Bearing courseBeforeManeuver = competitorTrack.getEstimatedSpeed(timePointBeforeManeuver).getBearing(); - final Bearing courseAfterManeuver = competitorTrack.getEstimatedSpeed(timePointAfterManeuver).getBearing(); - BearingChangeAnalyzer bearingChangeAnalyzer = BearingChangeAnalyzer.INSTANCE; - boolean jibed = bearingChangeAnalyzer.didPass(courseBeforeManeuver, totalCourseChangeInDegrees, courseAfterManeuver, wind.getBearing()); - boolean tacked = bearingChangeAnalyzer.didPass(courseBeforeManeuver, totalCourseChangeInDegrees, courseAfterManeuver, wind.getFrom()); - if (tacked && jibed) { - maneuverType = ManeuverType.PENALTY_CIRCLE; - if (legBeforeManeuver != null) { - maneuverLoss = legBeforeManeuver.getManeuverLoss(timePointBeforeManeuver, maneuverTimePoint, - timePointAfterManeuver); + final SpeedWithBearing estimatedSpeedBeforeManeuver = competitorTrack.getEstimatedSpeed(timePointBeforeManeuver); + final SpeedWithBearing estimatedSpeedAfterManeuver = competitorTrack.getEstimatedSpeed(timePointAfterManeuver); + if (wind != null && estimatedSpeedBeforeManeuver != null && estimatedSpeedAfterManeuver != null) { + BearingChangeAnalyzer bearingChangeAnalyzer = BearingChangeAnalyzer.INSTANCE; + final Bearing courseBeforeManeuver = estimatedSpeedBeforeManeuver.getBearing(); + final Bearing courseAfterManeuver = estimatedSpeedAfterManeuver.getBearing(); + boolean jibed = bearingChangeAnalyzer.didPass(courseBeforeManeuver, totalCourseChangeInDegrees, + courseAfterManeuver, wind.getBearing()); + boolean tacked = bearingChangeAnalyzer.didPass(courseBeforeManeuver, totalCourseChangeInDegrees, + courseAfterManeuver, wind.getFrom()); + if (tacked && jibed) { + maneuverType = ManeuverType.PENALTY_CIRCLE; + if (legBeforeManeuver != null) { + maneuverLoss = legBeforeManeuver.getManeuverLoss(timePointBeforeManeuver, maneuverTimePoint, + timePointAfterManeuver); + } + } else if (tacked) { + maneuverType = ManeuverType.TACK; + if (legBeforeManeuver != null) { + maneuverLoss = legBeforeManeuver.getManeuverLoss(timePointBeforeManeuver, maneuverTimePoint, + timePointAfterManeuver); + } + } else if (jibed) { + maneuverType = ManeuverType.JIBE; + if (legBeforeManeuver != null) { + maneuverLoss = legBeforeManeuver.getManeuverLoss(timePointBeforeManeuver, maneuverTimePoint, + timePointAfterManeuver); + } + } else { + // heading up or bearing away + Bearing windBearing = wind.getBearing(); + Bearing toWindBeforeManeuver = windBearing.getDifferenceTo(speedWithBearingOnApproximationAtBeginning.getBearing()); + Bearing toWindAfterManeuver = windBearing.getDifferenceTo(speedWithBearingOnApproximationAtEnd.getBearing()); + maneuverType = Math.abs(toWindBeforeManeuver.getDegrees()) < Math.abs(toWindAfterManeuver.getDegrees()) ? ManeuverType.HEAD_UP + : ManeuverType.BEAR_AWAY; } - } else if (tacked) { - maneuverType = ManeuverType.TACK; - if (legBeforeManeuver != null) { - maneuverLoss = legBeforeManeuver.getManeuverLoss(timePointBeforeManeuver, maneuverTimePoint, - timePointAfterManeuver); - } - } else if (jibed) { - maneuverType = ManeuverType.JIBE; - if (legBeforeManeuver != null) { - maneuverLoss = legBeforeManeuver.getManeuverLoss(timePointBeforeManeuver, maneuverTimePoint, - timePointAfterManeuver); - } - } else { - // heading up or bearing away - Bearing windBearing = wind.getBearing(); - Bearing toWindBeforeManeuver = windBearing.getDifferenceTo(speedWithBearingOnApproximationAtBeginning - .getBearing()); - Bearing toWindAfterManeuver = windBearing - .getDifferenceTo(speedWithBearingOnApproximationAtEnd.getBearing()); - maneuverType = Math.abs(toWindBeforeManeuver.getDegrees()) < Math.abs(toWindAfterManeuver.getDegrees()) ? ManeuverType.HEAD_UP - : ManeuverType.BEAR_AWAY; + final Maneuver maneuver = new ManeuverImpl(maneuverType, tackAfterManeuver, maneuverPosition, + maneuverTimePoint, speedWithBearingOnApproximationAtBeginning, + speedWithBearingOnApproximationAtEnd, totalCourseChangeInDegrees, maneuverLoss); + result.add(maneuver); } - final Maneuver maneuver = new ManeuverImpl(maneuverType, tackAfterManeuver, maneuverPosition, - maneuverTimePoint, speedWithBearingOnApproximationAtBeginning, speedWithBearingOnApproximationAtEnd, - totalCourseChangeInDegrees, maneuverLoss); - result.add(maneuver); return result; } From 0f585068f29714012618d54bf774bd7f4d1473a7 Mon Sep 17 00:00:00 2001 From: Frederik Petersen Date: Tue, 18 Mar 2014 15:25:50 +0100 Subject: [PATCH 2/6] Added wind export checkbox in master data import panel allows the user to disable the wind export/import, which will lead to significantly smaller data sizes --- .../masterdataimport/TopLevelMasterData.java | 9 +++++-- .../sailing/gwt/ui/client/SailingService.java | 2 +- .../gwt/ui/client/SailingServiceAsync.java | 1 + .../sailing/gwt/ui/client/StringMessages.java | 2 ++ .../gwt/ui/client/StringMessages.properties | 4 +++- .../ui/client/StringMessages_de.properties | 4 +++- .../MasterDataImportPanel.java | 10 +++++++- .../gwt/ui/server/SailingServiceImpl.java | 13 ++++------ .../gateway/jaxrs/spi/MasterDataResource.java | 8 +++++-- .../server/test/MasterDataImportTest.java | 24 +++++++++---------- 10 files changed, 49 insertions(+), 28 deletions(-) diff --git a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/masterdataimport/TopLevelMasterData.java b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/masterdataimport/TopLevelMasterData.java index 054c493e55d..1463c9d4ef8 100644 --- a/java/com.sap.sailing.domain/src/com/sap/sailing/domain/masterdataimport/TopLevelMasterData.java +++ b/java/com.sap.sailing.domain/src/com/sap/sailing/domain/masterdataimport/TopLevelMasterData.java @@ -37,12 +37,17 @@ public class TopLevelMasterData implements Serializable { private final Map> eventForLeaderboardGroup; public TopLevelMasterData(final Set groupsToExport, final Iterable allEvents, - final Map regattaForRaceIdString, final Collection allMediaTracks) { + final Map regattaForRaceIdString, final Collection allMediaTracks, + boolean exportWind) { this.raceIdStringsForRegatta = convertToRaceIdStringsForRegattaMap(regattaForRaceIdString); this.allMediaTracks = new HashSet(); this.allMediaTracks.addAll(allMediaTracks); this.leaderboardGroups = groupsToExport; - this.windTrackMasterData = fillWindMap(groupsToExport); + if (exportWind) { + this.windTrackMasterData = fillWindMap(groupsToExport); + } else { + this.windTrackMasterData = new HashSet(); + } this.eventForLeaderboardGroup = createEventMap(groupsToExport, allEvents); } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingService.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingService.java index 3a682c82834..eddd286ac34 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingService.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingService.java @@ -345,7 +345,7 @@ public interface SailingService extends RemoteService { List getLeaderboardGroupNamesFromRemoteServer(String host); - UUID importMasterData(String host, String[] groupNames, boolean override, boolean compress); + UUID importMasterData(String host, String[] groupNames, boolean override, boolean compress, boolean exportWind); DataImportProgress getImportOperationProgress(UUID id); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingServiceAsync.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingServiceAsync.java index eaa6e2d9a84..2941dccf2eb 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingServiceAsync.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/SailingServiceAsync.java @@ -471,6 +471,7 @@ public interface SailingServiceAsync { AsyncCallback callback); void importMasterData(String host, String[] names, boolean override, boolean compress, + boolean exportWind, AsyncCallback asyncCallback); void getImportOperationProgress(UUID id, AsyncCallback asyncCallback); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java index 15c6f96068d..8318201ddd5 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.java @@ -966,4 +966,6 @@ public interface StringMessages extends Messages { String overallProgress(); String showAddedScores(); String ratio(); + String importWind(); + String importWindTooltip(); } diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties index 4dab0a69cea..dffb19f81a9 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages.properties @@ -954,4 +954,6 @@ overallProgress=Overall Progress eventOverview=Event Overview start=Start showAddedScores=Show added scores for each entry in leaderboard -ratio=ratio \ No newline at end of file +ratio=ratio +importWind=Import Wind +importWindTooltip=Unchecking this option will drastically lower the amount of data transfered. \ No newline at end of file diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties index 9ec0874362a..eb104db3d22 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/client/StringMessages_de.properties @@ -950,4 +950,6 @@ overallProgress=Gesamtfortschritt eventOverview=Veranstaltungsübersicht start=Start showAddedScores=Addierte Punkte für jeden Eintrag im Leaderboard anzeigen -ratio=Verhältnis \ No newline at end of file +ratio=Verhältnis +importWind=Wind importieren +importWindTooltip=Diese Option zu deselektieren führt zu einer wesentlich kleineren übertragenen Datenmenge. \ No newline at end of file diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/masterdataimport/MasterDataImportPanel.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/masterdataimport/MasterDataImportPanel.java index 2e342657494..00706358012 100644 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/masterdataimport/MasterDataImportPanel.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/masterdataimport/MasterDataImportPanel.java @@ -52,6 +52,7 @@ public class MasterDataImportPanel extends VerticalPanel { private final EventRefresher eventRefresher; private final LeaderboardGroupRefresher leaderboardGroupRefresher; private CheckBox compressSwitch; + private CheckBox exportWindSwitch; private TextBox filterBox; public MasterDataImportPanel(StringMessages stringMessages, SailingServiceAsync sailingService, @@ -126,7 +127,9 @@ public class MasterDataImportPanel extends VerticalPanel { disableAllButtons(); boolean override = overrideSwitch.getValue(); boolean compress = compressSwitch.getValue(); - sailingService.importMasterData(currentHost, groupNames, override, compress, new AsyncCallback() { + boolean exportWind = exportWindSwitch.getValue(); + sailingService.importMasterData(currentHost, groupNames, override, compress, exportWind, + new AsyncCallback() { @Override public void onFailure(Throwable caught) { @@ -326,6 +329,11 @@ public class MasterDataImportPanel extends VerticalPanel { compressSwitch.setValue(true); contentPanel.add(compressSwitch); + exportWindSwitch = new CheckBox(stringMessages.importWind()); + exportWindSwitch.setTitle(stringMessages.importWindTooltip()); + exportWindSwitch.setValue(true); + contentPanel.add(exportWindSwitch); + importLeaderboardGroupsButton = new Button(stringMessages.importSelectedLeaderboardGroups()); importLeaderboardGroupsButton.setEnabled(false); contentPanel.add(importLeaderboardGroupsButton); diff --git a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/SailingServiceImpl.java b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/SailingServiceImpl.java index 802ebc0cd23..e55492cc85f 100755 --- a/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/SailingServiceImpl.java +++ b/java/com.sap.sailing.gwt.ui/src/main/java/com/sap/sailing/gwt/ui/server/SailingServiceImpl.java @@ -3455,7 +3455,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S @Override public UUID importMasterData(final String urlAsString, final String[] groupNames, final boolean override, - final boolean compress) { + final boolean compress, final boolean exportWind) { final UUID importOperationId = UUID.randomUUID(); getService().createOrUpdateDataImportProgressWithReplication(importOperationId, 0.0, "Initializing", 0.0); // Create a progress indicator for as long as the server gets data from the other server. @@ -3472,7 +3472,7 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S int port = hostnameAndPort.getB(); String query; try { - query = createLeaderboardQuery(groupNames, compress); + query = createLeaderboardQuery(groupNames, compress, exportWind); } catch (UnsupportedEncodingException e1) { throw new RuntimeException(e1); } @@ -3550,17 +3550,14 @@ public class SailingServiceImpl extends ProxiedRemoteServiceServlet implements S return getService().getDataImportLock().getProgress(id); } - private String createLeaderboardQuery(String[] groupNames, boolean compress) throws UnsupportedEncodingException { + private String createLeaderboardQuery(String[] groupNames, boolean compress, boolean exportWind) + throws UnsupportedEncodingException { StringBuffer queryStringBuffer = new StringBuffer(""); for (int i = 0; i < groupNames.length; i++) { String encodedGroupName = URLEncoder.encode(groupNames[i], "UTF-8"); queryStringBuffer.append("names[]=" + encodedGroupName + "&"); } - if (compress) { - queryStringBuffer.append("compress=true"); - } else { - queryStringBuffer.deleteCharAt(queryStringBuffer.length() - 1); - } + queryStringBuffer.append(String.format("compress=%s&exportWind=%s", compress, exportWind)); return queryStringBuffer.toString(); } diff --git a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/spi/MasterDataResource.java b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/spi/MasterDataResource.java index 73872445568..521f96fe252 100644 --- a/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/spi/MasterDataResource.java +++ b/java/com.sap.sailing.server.gateway/src/com/sap/sailing/server/gateway/jaxrs/spi/MasterDataResource.java @@ -37,12 +37,16 @@ public class MasterDataResource extends AbstractSailingServerResource { @GET @Produces("application/x-java-serialized-object") public Response getMasterDataByLeaderboardGroups(@QueryParam("names[]") List leaderboardGroupNames, - @QueryParam("compress") Boolean compress) throws UnsupportedEncodingException { + @QueryParam("compress") Boolean compress, @QueryParam("exportWind") Boolean exportWind) + throws UnsupportedEncodingException { final long startTime = System.currentTimeMillis(); logger.info("Masterdataexport has started"); if (compress == null) { compress = false; } + if (exportWind == null) { + exportWind = true; + } logger.info(String.format("Masterdataexport gzip compression is turned %s", compress ? "on" : "off")); Map allLeaderboardGroups = getService().getLeaderboardGroups(); @@ -72,7 +76,7 @@ public class MasterDataResource extends AbstractSailingServerResource { final TopLevelMasterData masterData = new TopLevelMasterData(groupsToExport, getService().getAllEvents(), getService().getPersistentRegattasForRaceIDs(), getService() - .getAllMediaTracks()); +.getAllMediaTracks(), exportWind); ResponseBuilder resp; if (compress) { diff --git a/java/com.sap.sailing.server.test/src/com/sap/sailing/server/test/MasterDataImportTest.java b/java/com.sap.sailing.server.test/src/com/sap/sailing/server/test/MasterDataImportTest.java index 81c28a6967a..f7b7969fdde 100755 --- a/java/com.sap.sailing.server.test/src/com/sap/sailing/server/test/MasterDataImportTest.java +++ b/java/com.sap.sailing.server.test/src/com/sap/sailing/server/test/MasterDataImportTest.java @@ -255,7 +255,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -443,7 +443,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -577,7 +577,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -727,7 +727,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -888,7 +888,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -1084,7 +1084,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -1230,7 +1230,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -1353,7 +1353,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -1488,7 +1488,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -1551,7 +1551,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -1671,7 +1671,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); @@ -1742,7 +1742,7 @@ public class MasterDataImportTest { DomainFactory domainFactory; MasterDataResource resource = new MasterDataResource(); MasterDataResource spyResource = spyResource(resource, sourceService); - Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false); + Response response = spyResource.getMasterDataByLeaderboardGroups(groupNamesToExport, false, true); StreamingOutput streamingOutput = (StreamingOutput) response.getEntity(); ByteArrayOutputStream os = new ByteArrayOutputStream(); UUID randomUUID = UUID.randomUUID(); From e3097e1dd6e6a844a1ad930ac3c052a49f14f23c Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 18 Mar 2014 15:31:51 +0100 Subject: [PATCH 3/6] fixing bug 1857 by using equalsWithNull in Util where an iterable may contain null values --- .../src/com/sap/sailing/domain/common/impl/Util.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/impl/Util.java b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/impl/Util.java index 2d1a1c79a4a..9f3d0d83b95 100755 --- a/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/impl/Util.java +++ b/java/com.sap.sailing.domain.common/src/com/sap/sailing/domain/common/impl/Util.java @@ -75,7 +75,7 @@ public class Util { while (aIter.hasNext() && bIter.hasNext()) { T ao = aIter.next(); T bo = bIter.next(); - if (!ao.equals(bo)) { + if (!equalsWithNull(ao, bo)) { return false; } } @@ -101,7 +101,7 @@ public class Util { return ((Collection) ts).contains(t); } else { for (T t2 : ts) { - if (t2.equals(t)) { + if (equalsWithNull(t2, t)) { return true; } } From 896335b9afa7febce6de39c780220b50d84fb834 Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 18 Mar 2014 15:50:36 +0100 Subject: [PATCH 4/6] added test for bug 1857 --- .../sailing/domain/common/test/UtilTest.java | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100755 java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/common/test/UtilTest.java diff --git a/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/common/test/UtilTest.java b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/common/test/UtilTest.java new file mode 100755 index 00000000000..05f1bcedc31 --- /dev/null +++ b/java/com.sap.sailing.domain.test/src/com/sap/sailing/domain/common/test/UtilTest.java @@ -0,0 +1,45 @@ +package com.sap.sailing.domain.common.test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.Before; +import org.junit.Test; + +import com.sap.sailing.domain.common.impl.Util; + +public class UtilTest { + private List l; + + @Before + public void setUp() { + l = new ArrayList<>(); + l.add(1); + l.add(2); + l.add(null); + l.add(4); + } + + @Test + public void testContainsWithNull() { + assertTrue(Util.contains(l, 1)); + assertFalse(Util.contains(l, 5)); + assertTrue(Util.contains(l, null)); + } + + @Test + public void testContainsWithoutNull() { + l.remove(null); + assertFalse(Util.contains(l, null)); + } + + @Test + public void testIndexOfWithNull() { + assertEquals(0, Util.indexOf(l, 1)); + assertEquals(2, Util.indexOf(l, null)); + } +} From d5daa8ee0fa90434545e065710660f5931f302da Mon Sep 17 00:00:00 2001 From: Axel Uhl Date: Tue, 18 Mar 2014 21:04:33 +0100 Subject: [PATCH 5/6] fixing bug 1863 by adjusting the minMaxBackgroundBar style to use the renamed yellowBar.png instead of greyBar.png --- java/com.sap.sailing.gwt.ui/CommonControls.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/java/com.sap.sailing.gwt.ui/CommonControls.css b/java/com.sap.sailing.gwt.ui/CommonControls.css index 86ac829d7e7..a5cf6530cd1 100644 --- a/java/com.sap.sailing.gwt.ui/CommonControls.css +++ b/java/com.sap.sailing.gwt.ui/CommonControls.css @@ -692,7 +692,7 @@ body ::-webkit-scrollbar-track { .minMaxBackgroundBar { left: 0px; - background-image: url(images/greyBar.png); + background-image: url(images/yellowBar.png); background-position: left; background-repeat: no-repeat; } From 569a5431d6c29afc960dcd61d67417486a5944bf Mon Sep 17 00:00:00 2001 From: Frank Mittag Date: Wed, 19 Mar 2014 09:53:26 +0000 Subject: [PATCH 6/6] Updated typical development scenarios (markdown) --- wiki/typical-development-scenarios.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/wiki/typical-development-scenarios.md b/wiki/typical-development-scenarios.md index 7526d6bc779..694189676d1 100644 --- a/wiki/typical-development-scenarios.md +++ b/wiki/typical-development-scenarios.md @@ -46,6 +46,21 @@ Whenever you add another GWT RPC service, make sure to add it to the list of ser * Add the library to our central maven repository /home/trac/maven-repositories by using the mvn: install:install-file command * Command sample to add the library gwt-maps-api-3.9.0-build-17.jar: mvn install:install-file -Dfile=/home/trac/git/java/com.sap.sailing.gwt.ui/WEB-INF/lib/gwt-maps-api-3.9.0-build-17.jar -DgroupId=com.github.branflake2267 -DartifactId=gwt-maps-api -Dversion=3.9.0-build-17 -Dpackaging=jar -DlocalRepositoryPath=/home/trac/maven-repositories +## Adding a shared GWT library bundle + +Sometimes we need a bundle containing code and resources which can be used by other GWT bundles (GWT library). +To create and use such a bundle from another GWT bundle (e.g. com.sap.sailing.gwt.ui) some additional steps compared to the normal Java bundle creation are required. + +GWT library bundle project creation +* Add a new Java plugin project, using /java/ as the project directory +* Add the GWT-SDK dependency to the project +* Add a GWT module file to project (ModuleName.gwt.xml) +* Add the bundle to the main pom.xml in /git/java + +Use the GWT library project in a GWT UI project +* Add the src folder of the GWT library bundle to classpath of all GWT-Launch configurations (required to let the GWT dev mode find the sources of java classes) -> Open GWT launch config, select tab 'classpath', select 'User entries', click 'Advanced' button, choose 'add folders' option and add the src folder of the GWT library project +* Add the bundle the pom.xml of the GWT UI project (for the maven build) + ## Adding an GWT Extension Library (With Source Code) TODO (see Highcharts example)